On Wed, Oct 2, 2024 at 3:07 PM Mandolyte <cecil....@gmail.com> wrote:

> What did I do wrong?

Copying the go.mod file effectively declares the code in hello.go to be in
package modernc.org/tk9.0.
That's the package hello.go imports, hence the import cycle. This works
here:

jnml@t3610:~/tmp$ mkdir tk
jnml@t3610:~/tmp$ cd tk
/home/jnml/tmp/tk
jnml@t3610:~/tmp/tk$ ls -la
total 8
drwxr-xr-x  2 jnml jnml 4096 Oct  2 15:15 .
drwxr-xr-x 17 jnml jnml 4096 Oct  2 15:15 ..
jnml@t3610:~/tmp/tk$ cp ~/src/modernc.org/tk9.0/_examples/hello.go .
jnml@t3610:~/tmp/tk$ go mod init example.com/hello
go: creating new go.mod: module example.com/hello
go: to add module requirements and sums:
go mod tidy
jnml@t3610:~/tmp/tk$ go mod tidy
go: finding module for package modernc.org/tk9.0
go: found modernc.org/tk9.0 in modernc.org/tk9.0 v0.29.1
jnml@t3610:~/tmp/tk$ CGO_ENABLED=0 go run hello.go
jnml@t3610:~/tmp/tk$

Hope this helps.

-j

-- 
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/CAA40n-Xn2N5gWOZt%3DgEa%3DgHieh-MU7ZhC68Hsgd8QusfrYsObg%40mail.gmail.com.

Reply via email to