> They are just simple go programs that work like perl or python programs, 
designed to take work with pipes

You still should have a go.mod.  Even if you don't intend to publish your 
code anywhere, you give it a module name - anything will do as long as it 
meets the syntax requirements.
See example 
here: https://groups.google.com/g/golang-nuts/c/SUWXeLjuWY0/m/fg9nhD47DwAJ

Then you need "go test ." not "go test" (notice the dot)

> There are really no need for packages or modules for these programs.

These days, anything other than a trivial hello-world type program should 
have a go.mod.  As soon as you start importing any third party libraries 
you most definitely need it.

You will always have a package - at least package "main".

If you need to split your code into other packages, you can put those in 
subdirectories.  Those don't need their own go.mod files.  The path for 
each package is the path from the outer go.mod file, concatenated with the 
subdirectory.

On Friday, 18 November 2022 at 14:18:50 UTC pat2...@gmail.com wrote:

> OK, all the source files are in the same directory
> I did the go mod
> it didn't work as you typed, but I got it to work
>
> I'm pretty sure I don't understand packages and modules.
> I really an not using any of that, I just have a half dozen go files some 
> with main() and
> some with tests.
>
> I am now getting a different error message:
> $ go test
> found packages main (csvtsd.go) and quaternion (quaternion.go) in 
> C:\Users\pfarrell\sandbox\gows\src\github.com\pfarrell51\cmd
> pfarrell@Alien15:~/whome/sandbox/gows/src/github.com/pfarrell51/cmd$
>
> after doing this:
>
>
> $ go mod init
> go: cannot determine module path for source directory 
> C:\Users\pfarrell\sandbox\gows (outside GOPATH, module path must be 
> specified)
>
> Example usage:
>         'go mod init example.com/m' to initialize a v0 or v1 module
>         'go mod init example.com/m/v2' to initialize a v2 module
>
> Run 'go help mod init' for more information.
>
> $ go mod init src/github.com/pfarrell51/cmd/
> go: malformed module path "src/github.com/pfarrell51/cmd/": trailing slash
>
> $ go mod init src/github.com/pfarrell51/cmd
> go: creating new go.mod: module src/github.com/pfarrell51/cmd
> go: to add module requirements and sums:
>         go mod tidy
> pfarrell@Alien15:~/whome/sandbox/gows$ go mod tidy
>
>
> $ go test
> found packages main (csvtsd.go) and quaternion (quaternion.go) in 
> C:\Users\pfarrell\sandbox\gows\src\github.com\pfarrell51\cmd
>
>
> It seems to be missing two test.go files in the directory:
> $ ls *test.go
> csvtsd_test.go  goprorename_test.go  quaternion_test.go  treesort_test.go
>
> There are really no need for packages or modules for these programs.
> They are just simple go programs that work like perl or python programs, 
> designed to take work with pipes
> Some have package names because the source I pulled from random places had 
> a package line.
>
>
>

-- 
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/b070d88a-4085-4fea-9d5b-4ba5d6422079n%40googlegroups.com.

Reply via email to