The best advice is: Read How to Write Go Code https://golang.org/doc/code.html and stick to it.
Yes, modules are the thing to be used 1. But naming a module "src" is begging for trouble. Name your module either something like julesgocode.org/firsttry or maybe github.com/<yourgithubnamehere>/firsttry 2. If your package jsonstuff lifes in module "julesgocode.org/firsttry" then its import path is "julesgocode.org/firsttry/jsonstuff". One thing a lot of Go newcomers seem to have trouble with is the fact that the go tool works best on packages and _not_ on files: You dop not import files and you do not run files and you do not test files. Files contain the sources but are basically uninteresting: Focus on packages (and modules). Packages life in modules. Modules have a _sensible_ name or might even point directly to your revision control system. Packages are named like the filesystem folder the are contained. Importing happens by "full qualified import path", i.e. <full-name-of-module>/<relative-FS-path-inside-module> This is not the whole truth but the basic essence of how you should work. V. On Wednesday, 29 July 2020 19:51:59 UTC+2, jules wrote: > > Thanks Kurtis and Jake. Adding jsonstuff.Prices fixed it. > I have a second question related to weird behavior of using modules: > ------------------------------------------------------- > $ go run main.go > Hello golang > {0} > $ go env | egrep PATH > GOPATH="/home/jfields/go" > > $ rm go.mod > $ go mod init src > go: creating new go.mod: module src > $ more go.mod > module src > > go 1.14 > $ go run main.go > main.go:7:2: package jsonstuff is not in GOROOT > (/usr/local/go/src/jsonstuff) > $ ls /home/jfields/go/src/jsonstuff > typestuff.go > $ rm go.mod > $ go run main.go > Hello golang > {0} > ----------------------------------------------------------- > I read somewhere we are supposed to use modules now. When tried making a > go.mod file, program failed to find package jsonstuff? > Had to delete go.mod to get it to compile? > Sorry, another newbie question. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/71563235-2ccb-4820-a0b1-7147a2cefa0eo%40googlegroups.com.