Skip to content

go compiler: file named windows.go is not being compiled #8361

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

Closed
gopherbot opened this issue Jul 11, 2014 · 3 comments
Closed

go compiler: file named windows.go is not being compiled #8361

gopherbot opened this issue Jul 11, 2014 · 3 comments

Comments

@gopherbot
Copy link
Contributor

by aklyachkin:

Before filing a bug, please check whether it has been fixed since the
latest release. Search the issue tracker and check that you're running the
latest version of Go:

Run "go version" and compare against
http://golang.org/doc/devel/release.html  If a newer version of Go exists,
install it and retry what you did to reproduce the problem.

Thanks.

What does 'go version' print?

[andrewk@macaque-2]:~/src/g1$ go version
go version go1.3 darwin/amd64

What steps reproduce the problem?

[andrewk@macaque-2]:~/src$ mkdir g1
[andrewk@macaque-2]:~/src$ cd g1
[andrewk@macaque-2]:~/src/g1$ ls
[andrewk@macaque-2]:~/src/g1$ export GOPATH=/Users/andrewk/src/g1
[andrewk@macaque-2]:~/src/g1$ cat >windows.go
package main

import "fmt"

func main() {
    fmt.Println("Hello, world")
}
[andrewk@macaque-2]:~/src/g1$ go build
can't load package: package .: no buildable Go source files in /Users/andrewk/src/g1
[andrewk@macaque-2]:~/src/g1$ ls
windows.go
[andrewk@macaque-2]:~/src/g1$ go build -work -x
WORK=/var/folders/9p/bnyfm2md0q5_j4wb3zh9_yq00000gn/T/go-build620868854
can't load package: package .: no buildable Go source files in /Users/andrewk/src/g1


[andrewk@macaque-2]:~/src/g1$ mv windows.go main.go
[andrewk@macaque-2]:~/src/g1$ go build -work -x
WORK=/var/folders/9p/bnyfm2md0q5_j4wb3zh9_yq00000gn/T/go-build049576138
mkdir -p $WORK/_/Users/andrewk/src/g1/_obj/
cd /Users/andrewk/src/g1
/opt/local/go/pkg/tool/darwin_amd64/6g -o $WORK/_/Users/andrewk/src/g1.a -trimpath $WORK
-p _/Users/andrewk/src/g1 -complete -D _/Users/andrewk/src/g1 -I $WORK -pack ./main.go
cd .
/opt/local/go/pkg/tool/darwin_amd64/6l -o g1 -L $WORK -extld=/usr/bin/clang
$WORK/_/Users/andrewk/src/g1.a
[andrewk@macaque-2]:~/src/g1$ ls
g1*      main.go


What happened?

If file named "windows.go", go compiler doesn't see and compile it.

What should have happened instead?

File should be compiled regardless of its name

Please provide any additional information below.
@gopherbot
Copy link
Contributor Author

Comment 1 by aklyachkin:

I found, that linux.go has the same problem with compilation.
[andrewk@macaque-2]:~/src/g1$ ls
linux.go
[andrewk@macaque-2]:~/src/g1$ go build
can't load package: package .: no buildable Go source files in /Users/andrewk/src/g1

@bradfitz
Copy link
Contributor

Comment 2:

Files named after operating systems are only compiled on those operating systems.  See
the package docs for go/build. 
Search for "(example: windows.go)" at http://golang.org/pkg/go/build/
 I just learned this too in issue #8344.

Status changed to WorkingAsIntended.

@gopherbot
Copy link
Contributor Author

Comment 3 by aklyachkin:

Thank you Brad. If it is documented, it is obviously a feature, not a bug :-) the issue
can be closed, although I find this compiler behaviour a little bit disappointing. I
wanted to move my functions, which work with windows (UI windows, not MS Windows) to
another file. Ok, I use another name.

@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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

2 participants