Skip to content

Commit

Permalink
chore: update some code style and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Aug 9, 2022
1 parent 4ed0a18 commit adc55a9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
12 changes: 3 additions & 9 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,7 @@ func (c *Config) DelDriver(format string) {
*************************************************************/

// Name get config name
func (c *Config) Name() string {
return c.name
}
func (c *Config) Name() string { return c.name }

// Error get last error, will clear after read.
func (c *Config) Error() error {
Expand All @@ -203,14 +201,10 @@ func (c *Config) IsEmpty() bool {
}

// LoadedFiles get loaded files name
func (c *Config) LoadedFiles() []string {
return c.loadedFiles
}
func (c *Config) LoadedFiles() []string { return c.loadedFiles }

// DriverNames get loaded driver names
func (c *Config) DriverNames() []string {
return c.driverNames
}
func (c *Config) DriverNames() []string { return c.driverNames }

// ClearAll data and caches
func ClearAll() { dc.ClearAll() }
Expand Down
2 changes: 1 addition & 1 deletion options.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Options struct {
DecoderConfig *mapstructure.DecoderConfig
// HookFunc on data changed.
HookFunc HookFunc
// WatchChange bool
}

func newDefaultOption() *Options {
Expand All @@ -63,7 +64,6 @@ func newDefaultDecoderConfig() *mapstructure.DecoderConfig {
TagName: defaultStructTag,
// will auto convert string to int/uint
WeaklyTypedInput: true,
// DecodeHook: ValDecodeHookFunc,
}
}

Expand Down
5 changes: 3 additions & 2 deletions other/other.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"github.com/gookit/config/v2/ini"
)

const driverName = "other"
// DriverName string
const DriverName = "other"

var (
// Encoder is the encoder for this driver
Encoder = ini.Encoder
// Decoder is the decoder for this driver
Decoder = ini.Decoder
// Driver is the exported symbol
Driver = config.NewDriver(driverName, Decoder, Encoder)
Driver = config.NewDriver(DriverName, Decoder, Encoder)
)
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func ValDecodeHookFunc(parseEnv, parseTime bool) mapstructure.DecodeHookFunc {
}

// start char is number(1-9)
if str[0] > 48 && str[0] < 57 {
if str[0] > '0' && str[0] < '9' {
// parse time string. eg: 10s
if parseTime && t.Kind() == reflect.Int64 {
dur, err := time.ParseDuration(str)
Expand Down

0 comments on commit adc55a9

Please sign in to comment.