On Wednesday, February 26, 2020 at 8:53:52 PM UTC+1, geoff.j...@gmail.com 
wrote:
>
> Hello.
>
>
> > [...]
>
>
>
> So:
>
>    1. 
>    
>    I don’t understand why go build foo.com/foobar fails to find the 
>    module if it doesn’t contain some top-level .go file, but go list -m 
>    finds it perfectly fine.
>    
>
This fails with GOPATH mode, too:
can't load package: package foo.com/foobar: no Go files in 
.../foo.com/foobar

The problem is that the error message is incorrect/confusing.
I have tested with go1.14 and it is even more confusing:
can't load package: cannot find module providing package 
github.com/perillo/gocmd: invalid github.com/ import path 
"github.com/perillo"

>
>    1. 
>    
>    [How] can I have a module X that provides packages X/Y and X/Z, with 
>    no source files in the top-level package X? Or am I not supposed to do 
>    this under Go modules?
>    
>
Of course you can work with it.
Just do go build -o build. ./...
Note that this will fail if there are no main packages in the main module.

When cross compiling you can create a Makefile or shell script, that do:
mkdir -p build/$GOOS-$GOARCH
go build -o build/$GOOS-$GOARCH/ ./...


   1. 
   
   Go modules appear to break my assumption that “I just set GOOS and/or 
   GOARCH to cross-compile, and everything else just works”. The is (was?) 
   one of the biggest benefits of Go for me. I need to cross-compile for Linux 
   (ARM, AArch64 and AMD64) and Windows (AMD64) all the time.
   

I have to admit that I never noticed that go build installed executables in 
$GOBIN/$GOOS-$GOARCH.  I don't know the reason for the change.

> [...]

Manlio 

-- 
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/b452b48e-cf25-482e-941a-897cf23834c4%40googlegroups.com.

Reply via email to