Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: go get github.com/hajimehoshi/ebiten/examples/shader failed with no-main error #45615

Closed
hajimehoshi opened this issue Apr 18, 2021 · 6 comments

Comments

@hajimehoshi
Copy link
Member

hajimehoshi commented Apr 18, 2021

What version of Go are you using (go version)?

$ go version
go version go1.16.2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/hajimehoshi/Library/Caches/go-build"
GOENV="/Users/hajimehoshi/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/hajimehoshi/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/hajimehoshi/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.2"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/tmp/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/60/khbk2xqn1c5bml1byjn89dwc0000gn/T/go-build1521022541=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go mod init foo
go get github.com/hajimehoshi/ebiten/...

EDIT:

go mod init foo
go get github.com/hajimehoshi/ebiten/examples/shader

is better

What did you expect to see?

No errors

What did you see instead?

# github.com/hajimehoshi/ebiten/examples/shader
runtime.main_main·f: function main is undeclared in the main package

The shader package should include the main function.

I'm afraid I could not create a minimum case to reproduce this issue.

Thanks,

@seankhliao
Copy link
Member

you're missing either a main function or build tags to hide all the files

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@hajimehoshi
Copy link
Member Author

you're missing either a main function or build tags to hide all the files

This error is different from the other errors:

$ go get github.com/hajimehoshi/ebiten/examples/rotate
github.com/hajimehoshi/ebiten/examples/rotate: no Go source files
package github.com/hajimehoshi/ebiten/examples/rotate: build constraints exclude all Go files in /Users/hajimehoshi/go/pkg/mod/github.com/hajimehoshi/ebiten@v1.12.11/examples/rotate

$ go get github.com/hajimehoshi/ebiten/examples/shader
# github.com/hajimehoshi/ebiten/examples/shader
runtime.main_main·f: function main is undeclared in the main package

@hajimehoshi hajimehoshi reopened this Apr 18, 2021
@hajimehoshi hajimehoshi changed the title cmd/go: go get with ... failed with no-main error cmd/go: go get github.com/hajimehoshi/ebiten/examples/shader failed with no-main error Apr 18, 2021
@seankhliao
Copy link
Member

the code if v1.12.11 has unbuildtagged code without a main function

@hajimehoshi
Copy link
Member Author

hajimehoshi commented Apr 18, 2021

Right. So the odd thing is, when using ...,

go get github.com/hajimehoshi/ebiten/examples/...

complains only for shader package, not for the other project that are unbuildtagged.

@seankhliao
Copy link
Member

Only shader is a main program without build tags

$ cd examples
$ go list -f '{{ .Name }} {{ .Dir }}' ./...
twenty48 /home/arccy/tmp/ebiten/examples/2048/2048
blocks /home/arccy/tmp/ebiten/examples/blocks/blocks
keyboard /home/arccy/tmp/ebiten/examples/keyboard/keyboard
resources /home/arccy/tmp/ebiten/examples/resources
audio /home/arccy/tmp/ebiten/examples/resources/audio
fonts /home/arccy/tmp/ebiten/examples/resources/fonts
images /home/arccy/tmp/ebiten/examples/resources/images
blocks /home/arccy/tmp/ebiten/examples/resources/images/blocks
flappy /home/arccy/tmp/ebiten/examples/resources/images/flappy
keyboard /home/arccy/tmp/ebiten/examples/resources/images/keyboard
mascot /home/arccy/tmp/ebiten/examples/resources/images/mascot
platformer /home/arccy/tmp/ebiten/examples/resources/images/platformer
shader /home/arccy/tmp/ebiten/examples/resources/images/shader
main /home/arccy/tmp/ebiten/examples/shader

@hajimehoshi
Copy link
Member Author

generate.go didn't have the build tag on 1.12 and 2.0 branch (not master branch). This was my fault. Thank you for the insights.

@golang golang locked and limited conversation to collaborators Apr 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants