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.mo
Hola!
Based on your initial project layout you have a couple of issues. When
using the legacy gopath everything should ideally live under that path.
Imports then become relative to that root.
Your main lives outside of the root which works with go run but is not how
a project should be structured
Thanks Jesper and Volker.
After reading the article(s) and go help modules and a few blogs, I still
was not able to see why deleting go.mod makes the program import
jsonstuff package, and compile and run?
Modules are a great idea and I want to use them, but I can't get it to
compile
a "hello golang
On Thu, Jul 30, 2020 at 12:54 PM Volker Dobler
wrote:
> 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).
>
In Go, we disconnect the name of a file and the package in whic
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//firsttry
2. If your
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
On Tuesday, July 28, 2020 at 11:21:38 PM UTC-4 Kurtis Rader wrote:
> See https://golang.org/ref/spec#Import_declarations. By default importing
> a package requires using the package name to refer to any symbols it
> exports; e.g., "jsonstuff.Prices". You can do "import . jsonstuff" to allow
> a
See https://golang.org/ref/spec#Import_declarations. By default importing a
package requires using the package name to refer to any symbols it exports;
e.g., "jsonstuff.Prices". You can do "import . jsonstuff" to allow
accessing its public symbols without qualification. Google "go import
unqualifie
I'm new to golang and learning it in evenings with no one to ask questions
of. I have a local files:
Here is /home/jules/go/src/jsonstuff/typestuff.go :
package jsonstuff
type Prices struct {
BidPrice float64 `json:"p"`
}
Here is /