1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-11 10:18:08 +09:00
any-sync/config/config.go
2022-07-13 19:18:43 +03:00

38 lines
756 B
Go

package config
import (
"context"
"fmt"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app"
"github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger"
"gopkg.in/yaml.v3"
"io/ioutil"
)
const CName = "config"
func NewFromFile(path string) (c *Config, err error) {
c = &Config{}
data, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
if err = yaml.Unmarshal(data, c); err != nil {
return nil, err
}
return
}
type Config struct {
Anytype Anytype `yaml:"anytype"`
GrpcServer GrpcServer `yaml:"grpcServer"`
}
func (c *Config) Init(ctx context.Context, a *app.App) (err error) {
logger.NewNamed("config").Info(fmt.Sprint(*c))
return
}
func (c Config) Name() (name string) {
return CName
}