On Friday, 31 July 2020 04:55:50 UTC+2, jules wrote: > > Modules are a great idea and I want to use them, but I can't get it to > compile > a "hello golang" program even: > > ======================= > $ ls /home/jfields/go/src/jsonstuff > typestuff.go > $ 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) > $ rm go.mod > $ go run main.go > Hello golang > {0} > ========================= >
Once again: 1. Naming the module "src" is _wrong_. Do _not_ do this! Use "myfirst.project". 2. Do nut use go run. Use go build. (or at least, if there are _fundamental_ issues which prevent you from typing `go build` at least use `go run .`. 3. Now that your module is called "myfirst.project" the import path of package jsonstuff in main.go _must_ read import "myfirst.project/jsonstuff" You _must_ name your module properly and you _must_ use the proper import path. You code as is is _invalid_ and _cannot_ be compiled. You must follow the rules. You should delete everything and start afresh in the way described by How To Write Go Code. V. -- 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/b9988553-8172-48d0-95e0-dc396b15ac09o%40googlegroups.com.