Open Litarvan opened 6 years ago
Have you tried using build tags ? https://golang.org/pkg/go/build/. They are ideal to deal with your situation.
I don't think Go should accept/ignore any files by itself. This is an application specific behavior and should be handled by the programmer. Build tags are the way to go.
Even if it is a specifid behavior, the point of "go build ." is to ignore every files except the .go files, and some like .syso. Anyway, i was just saying that a clearer error would be nice ?
/cc @ianlancetaylor
All the Go toolchain does with a .syso file is turn it over to the external linker. It is the external linker that is producing that error message. I'm not clear on what the Go tools can do to get a better error, but I'm open for suggestions. I suppose the Go tool could say something like "by the way, when the linker failed just then, we were passing it a .syso file."
The Go linker could give the file a more helpful name than 000000.o
, maybe 000000_resource_syso.o
or something like that?
At the point where the linker is invoked, the .syso file has been stuffed into an archive, and the name has potentially been truncated. I don't think we should print a truncated name, and I don't feel like going to the effort of preserving the original name.
I have been looking at alternative uses of .syso
files. They are a good mechanism for generically linking against library archives whether or not they contain Windows resources. So, I'd actually recommend closing this issue as working as intended. With the ability to have names like some_linux_arm64.syso and some_windows.syso and the linker and archive tool doing the right thing, I think the request here doesn't really need more work from the go team.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?What did you do?
I did, on linux,
go build .
on a project firstly created on Windows, containing amain.go
file but also aresource.syso
file generated with winres, that contains my icon file for the windows executable. The build was from linux this time, targeting linux, so i didn't pay attention to the .syso file.What did you expect to see?
A working build
What did you see instead?
go build .
dropped this error :It took me like 1 hour to think that
go build
was trying to include the .syso file even when i was on linux, and was crashing the build because of this, i didn't really pay attention to the command as it was issued by a script.go build should ignore .syso file on systems other than windows, or (i don't know if .syso is a windows-only extension) display a more readable error