Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toml cannot be used map #79

Open
xweis opened this issue Apr 12, 2019 · 1 comment
Open

Toml cannot be used map #79

xweis opened this issue Apr 12, 2019 · 1 comment

Comments

@xweis
Copy link

xweis commented Apr 12, 2019

#config.toml 
title       = "blabla"
[servers]
    [servers.a]
    ip      = "1.1.1.1"
    dc      = "abc"
    [servers.b]
    ip      = "2.2.2.2"
    dc      = "cba"


#main.go
type (
	WebSiteConfig struct {
		Title string
		Servers map[string]Server
	}
)

type Server struct {
		IP string
		DC string
}

func Load() *WebSiteConfig {
	config := new(WebSiteConfig)
	multiconfig.NewWithPath(LogPath). MustLoad(config)

	return config
}


#error 
panic: not struct

goroutine 1 [running]:
github.com/fatih/structs.strctVal(0xc0001c4500, 0xc0001b88f8, 0x16, 0xc0001c4500, 0xc0001b88f8)
        /Users/Xwei/go/src/github.com/fatih/structs/structs.go:437 +0x12f
github.com/fatih/structs.(*Field).FieldOk(0xc0002122d0, 0xc0002143c2, 0x1, 0xc0001ddc80, 0xc0001caa10)
        /Users/Xwei/go/src/github.com/fatih/structs/field.go:129 +0x98
github.com/fatih/structs.(*Field).Field(0xc0002122d0, 0xc0002143c2, 0x1, 0x157ad93)
        /Users/Xwei/go/src/github.com/fatih/structs/field.go:109 +0x3f
github.com/koding/multiconfig.(*EnvironmentLoader).processField(0xc0001c02a0, 0x1596ef3, 0xd, 0xc0002122d0, 0x157ad93, 0x7, 0x15fa320, 0xc0001b93b0, 0x0, 0x0)
        /Users/Xwei/go/src/github.com/koding/multiconfig/env.go:61 +0x164
github.com/koding/multiconfig.(*EnvironmentLoader).Load(0xc0001c02a0, 0x15c80e0, 0xc0001b88d0, 0x0, 0x0)


@AlanW0ng
Copy link

#config.toml 
title       = "blabla"
[servers]
    [servers.a]
    ip      = "1.1.1.1"
    dc      = "abc"
    [servers.b]
    ip      = "2.2.2.2"
    dc      = "cba"


#main.go
type (
	WebSiteConfig struct {
		Title string
		Servers map[string]Server
	}
)

type Server struct {
		IP string
		DC string
}

func Load() *WebSiteConfig {
	config := new(WebSiteConfig)
	multiconfig.NewWithPath(LogPath). MustLoad(config)

	return config
}


#error 
panic: not struct

goroutine 1 [running]:
github.com/fatih/structs.strctVal(0xc0001c4500, 0xc0001b88f8, 0x16, 0xc0001c4500, 0xc0001b88f8)
        /Users/Xwei/go/src/github.com/fatih/structs/structs.go:437 +0x12f
github.com/fatih/structs.(*Field).FieldOk(0xc0002122d0, 0xc0002143c2, 0x1, 0xc0001ddc80, 0xc0001caa10)
        /Users/Xwei/go/src/github.com/fatih/structs/field.go:129 +0x98
github.com/fatih/structs.(*Field).Field(0xc0002122d0, 0xc0002143c2, 0x1, 0x157ad93)
        /Users/Xwei/go/src/github.com/fatih/structs/field.go:109 +0x3f
github.com/koding/multiconfig.(*EnvironmentLoader).processField(0xc0001c02a0, 0x1596ef3, 0xd, 0xc0002122d0, 0x157ad93, 0x7, 0x15fa320, 0xc0001b93b0, 0x0, 0x0)
        /Users/Xwei/go/src/github.com/koding/multiconfig/env.go:61 +0x164
github.com/koding/multiconfig.(*EnvironmentLoader).Load(0xc0001c02a0, 0x15c80e0, 0xc0001b88d0, 0x0, 0x0)

+1, TOML map lead to "panic struct" error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants