srikanthops / gcfg

Automatically exported from code.google.com/p/gcfg
Other
0 stars 0 forks source link

do we need to import anything? #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
trying out one example, below are my files at a particular location

#config.gcfg
[production]
db-host = 127.0.0.1
db-password = hahahah

#main.go
package main

import "fmt"
import "gcfg"

func main() {
  var cfg Config
  err := gcfg.ReadFileInto(&cfg, "config.gcfg")
  fmt.Println(cfg)
}

# and the output with `import "gcfg"` is
main.go:4:8: import "gcfg": cannot find package

# and the output without `import "gcfg"` is
# command-line-arguments
./main.go:6: undefined: Config
./main.go:7: undefined: gcfg

Original issue reported on code.google.com by amolpuj...@gmail.com on 27 Mar 2013 at 1:47

GoogleCodeExporter commented 8 years ago
ohh, got it.

Original comment by amolpuj...@gmail.com on 27 Mar 2013 at 1:59

GoogleCodeExporter commented 8 years ago
Thanks for trying my package.

It seems that you have figured it out but I'll post it here for reference:
http://golang.org/cmd/go/#hdr-Remote_import_path_syntax
I omitted the import from the example on the project page as it is standard Go 
convention.

For more real-world examples, you can search for programs using 
"code.google.com/p/gcfg" on code sharing sites (e.g. github.com), here is one 
example:
https://github.com/abh/geodns/blob/ab821f706123806ac910132b96170dd1bdbd138a/conf
ig.go

Original comment by speter....@gmail.com on 27 Mar 2013 at 11:41