From 2250792ff8c3378efdfebbe1ff913b38f2a995a8 Mon Sep 17 00:00:00 2001 From: ktong Date: Tue, 14 Nov 2023 21:18:44 -0800 Subject: [PATCH] memory alignment --- config.go | 6 +++--- global.go | 2 -- provider/fs/fs.go | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/config.go b/config.go index 52eb63ba..c3b0a54c 100644 --- a/config.go +++ b/config.go @@ -19,13 +19,13 @@ import ( // Config is a registry which holds configuration loaded by Loader(s). type Config struct { + decodeHook mapstructure.DecodeHookFunc delimiter string tagName string - decodeHook mapstructure.DecodeHookFunc + onChanges *onChanges values *provider providers []*provider - onChanges *onChanges } type Unmarshaler interface { @@ -163,9 +163,9 @@ func (c Config) Watch(ctx context.Context) error { //nolint:cyclop,funlen } type provider struct { + values map[string]any watcher Watcher watchOnce sync.Once - values map[string]any } func (p *provider) sub(path string, delimiter string) any { diff --git a/global.go b/global.go index f08958d1..a28a2992 100644 --- a/global.go +++ b/global.go @@ -24,8 +24,6 @@ func Get[T any](path string) T { //nolint:ireturn "path", path, "type", reflect.TypeOf(value), ) - - return *new(T) } return value diff --git a/provider/fs/fs.go b/provider/fs/fs.go index 195dd032..dda26f60 100644 --- a/provider/fs/fs.go +++ b/provider/fs/fs.go @@ -22,9 +22,9 @@ import ( // FS is a Provider that loads configuration from file system. type FS struct { + unmarshal func([]byte, any) error fs fs.FS path string - unmarshal func([]byte, any) error ignoreNotExist bool }