Skip to content

Commit

Permalink
removed xerrors; changed the parameter order of iferr.Fail; removed L…
Browse files Browse the repository at this point in the history
…oadConfig from xconfig
  • Loading branch information
e-nikolov committed May 2, 2018
1 parent b01a662 commit e628cea
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 95 deletions.
4 changes: 2 additions & 2 deletions iferr/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ type Fataler interface {
Fatalf(format string, args ...interface{})
}

func Fail(err error, f Fataler) { Default.Fail(err, f) }
func (ie *IfErr) Fail(err error, f Fataler) {
func Fail(f Fataler, err error) { Default.Fail(f, err) }
func (ie *IfErr) Fail(f Fataler, err error) {
if err != nil {
f.Fatalf("%+v\n", err)
}
Expand Down
48 changes: 22 additions & 26 deletions xconfig/xconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,6 @@ import (
"github.com/unchainio/pkg/xpath"
)

func LoadConfig(cfg interface{}, path ...string) error {
return Load(cfg, FromPaths(path...))
}

type Options struct {
verbose bool

pathFlag *flag.Flag
paths []string

cfgType string
readers []io.Reader

remote *remoteConfig

automaticEnv bool

viper *viper.Viper
}

type remoteConfig struct {
provider, endpoint, path string
}

type OptionFunc func(*Options) error

func Load(cfg interface{}, optFuncs ...OptionFunc) error {
var err error
opts := &Options{}
Expand Down Expand Up @@ -122,6 +96,28 @@ func Load(cfg interface{}, optFuncs ...OptionFunc) error {
return nil
}

type OptionFunc func(*Options) error

type Options struct {
verbose bool

pathFlag *flag.Flag
paths []string

cfgType string
readers []io.Reader

remote *remoteConfig

automaticEnv bool

viper *viper.Viper
}

type remoteConfig struct {
provider, endpoint, path string
}

func Verbose(flag bool) OptionFunc {
return func(o *Options) error {
o.verbose = flag
Expand Down
67 changes: 0 additions & 67 deletions xerrors/xerrors.go

This file was deleted.

0 comments on commit e628cea

Please sign in to comment.