On Saturday, 10 December 2022 at 05:50:53 UTC pat2...@gmail.com wrote:
> thanks, and the playground is nice.
>
> I think this is saying that if I want a baz and bar executable (chmod +x)
> then I need the "package main" in separate folders/directories
>
Yes. The approach I use (which I borrowed
thanks, and the playground is nice.
I think this is saying that if I want a baz and bar executable (chmod +x)
then I need the "package main" in separate folders/directories
I don't think I'm close enough to understanding this stuff to focus on
optimizing it to
the fewest possible go.mod files,
Plus, you don't need to do a "go mod init" in each subdirectory. The
top-level directory names the module and the package within it; you can
refer to packages in subdirectories using this module name with the
subdirectory appended.
A typical layout would look like this:
(top level)
go mod
You cannot have multiple packages (in your case main and goprorename)
in one folder. This has nothing to do with modules. You must but these
three files into two different folders based on their package declaration.
You might want to work through https://go.dev/doc/code
V.
--
You received this
Thanks
I've read the official tutorial and your create-module docs.
They help, but I am still having issues getting this to hang together.
I got the treesort example to work.
Now I'm creating a new module, in a new subdirectory of my repositories
and I've done the go mod init
I have three go
Hi Pat,
FWIW, I pulled together a TLDR on modules some time ago that I think hits
upon each of the different issues you encountered in this thread. It also
tries to summarize the core modules concepts, along with a bit of advice on
how to stay on the "happy path" when starting out with Go
Thanks
That seems to be the solution
--
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
Your error comes from the spurious import of "treesort" in
treesort_test.go. (You are already inside package treesort; there is
nothing to import)
With this line:
$ go test .
# example.com/blah
treesort_test.go:11:2: package treesort is not in GOROOT
(/usr/local/go/src/treesort)
FAIL
On Wednesday, 23 November 2022 at 23:25:51 UTC pat2...@gmail.com wrote:
> I've separated my code into separate subdirectories, added a go.mod
> ran go mod tidy on each.
>
> I'm mostly back where I started, which a better source file tree
>
> I'm trying to test the "treesort" package from the
Show us the output of `which go`. I'm not convinced you're using a native
Linux Go compiler.
On Wed, Nov 23, 2022 at 5:31 PM pat2...@gmail.com
wrote:
> Just in case my use of the "windows installer" for go and then using
> WSL/bash
>
>> was confusing assorted magic env variables, I
In your reply to the request for `go env` output you say "For all of the
above I am using WSL (bash under Windows 11)". It looks like you're using
the native Windows Go toolchain from WSL. I would not expect that to work
and that is likely the reason you're having problems. You should install Go
Just in case my use of the "windows installer" for go and then using
WSL/bash
> was confusing assorted magic env variables, I uninstalled/deleted the
Windows installed version
then I downloaded the "linux" version, and did the usual "sudo tar " install
Made no difference
Get the same error
On Wednesday, November 23, 2022 at 7:00:35 PM UTC-5 kra...XXX wrote:
> On Windows Go is normally installed to C:\Program Files\Go. You should not
> put your source code inside that directory. Put the source for your
> projects somewhere else such as %HOME%/go.
>
My source files are not under
On Wednesday, November 23, 2022 at 6:31:51 PM UTC-5 se... wrote:
> output of `go env` please
>
I am using WSL (bash under Windows 11)
Shell env:
env
HOSTTYPE=x86_64
LESSCLOSE=/usr/bin/lesspipe %s %s
LANG=C.UTF-8
WSL_DISTRO_NAME=Ubuntu
USER=pfarrell
On Windows Go is normally installed to C:\Program Files\Go. You should not
put your source code inside that directory. Put the source for your
projects somewhere else such as %HOME%/go.
On Wed, Nov 23, 2022 at 3:26 PM pat2...@gmail.com
wrote:
> I've separated my code into separate
output of `go env` please
- sean
On Wed, Nov 23, 2022 at 11:25 PM pat2...@gmail.com
wrote:
> I've separated my code into separate subdirectories, added a go.mod
> ran go mod tidy on each.
>
> I'm mostly back where I started, which a better source file tree
>
> I'm trying to test the
I've separated my code into separate subdirectories, added a go.mod
ran go mod tidy on each.
I'm mostly back where I started, which a better source file tree
I'm trying to test the "treesort" package from the "Donovan and Kernigan"
The Go programing language book.
When I connect into the
On Monday, 21 November 2022 at 04:11:26 UTC pat2...@gmail.com wrote:
>
> Incidentally, there is no need to have github.com in the directory path
>> on your local filesystem. You could just use
>> ~/projects/cmd
>>
>
> Doesn't this contradict putting the github path in the name for easy
>
Thanks again
Bit of background, I've been playing with go on and off for five or six
years. I have decades of experience in
various systems programming languages, including things like TOPS-10 macro,
c, bliss, etc. Go is very
attractive to my systems-internals side.
About five years ago I
On Saturday, 19 November 2022 at 02:50:18 UTC pat2...@gmail.com wrote:
> On Friday, November 18, 2022 at 1:10:40 PM UTC-5 Brian Candler wrote:
>
>> 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
thanks
On Friday, November 18, 2022 at 1:10:40 PM UTC-5 Brian Candler wrote:
> 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.
>
OK, I can have a go.mod
But
> 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
On Fri, Nov 18, 2022 at 6:19 AM pat2...@gmail.com wrote:
>
> 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
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
On Thu, 2022-11-17 at 21:20 -0800, pat2...@gmail.com wrote:
> pfarrell@Alien15:~/whome/sandbox/gows/src/github.com/pfarrell51/cmd$
> go test treesort_test.go
This is not how go test should be invoked. You just need to do go test
in the directory that you package lives in.
See
Here I clear it, same result:
pfarrell@Alien15:~/whome/sandbox/gows/src/github.com/pfarrell51/cmd$ export
GOROOT=
pfarrell@Alien15:~/whome/sandbox/gows/src/github.com/pfarrell51/cmd$
printenv GOROOT
pfarrell@Alien15:~/whome/sandbox/gows/src/github.com/pfarrell51/cmd$ go
test treesort_test.go
On Thu, Nov 17, 2022 at 8:59 PM pat2...@gmail.com wrote:
>
> I'm missing something fundamental.
> I have set GOROOT to my current directory, which contains my go source files
> but I can't test a trivial program
In general you should never set GOROOT. It's a special purpose hook
that is almost
I'm missing something fundamental.
I have set GOROOT to my current directory, which contains my go source files
but I can't test a trivial program
treesort_test.go:11:2: package treesort is not in GOROOT (C:\Program
Files\Go\src\treesort)
It looks like the value of the GOROOT variable is set to
28 matches
Mail list logo