Jump to content

Talk:Go

From ArchWiki

gccgo vs gc

The gccgo compiler (from gcc-go) is usually slower to compile but generally has more optimizations than the gc compiler (from go).

The Go language has always been defined by a spec, not an implementation. The Go team has written two different compilers that implement that spec: gc and gccgo.
  • Gc is the original compiler, and the go tool uses it by default.
  • Gccgo is a different implementation with a different focus
Compared to gc, gccgo is slower to compile code but supports more powerful optimizations, so a CPU-bound program built by gccgo will usually run faster.
The gc compiler supports only the most popular processors: x86 (32-bit and 64-bit) and ARM.
Gccgo, however, supports all the processors that GCC supports.
Not all those processors have been thoroughly tested for gccgo, but many have, including x86 (32-bit and 64-bit), SPARC, MIPS, PowerPC and even Alpha.
Gccgo has also been tested on operating systems that the gc compiler does not support, notably Solaris.
Gccgo in GCC 4.7.1 (July 2012, slightly reformatted for clarity)

-- The Puzzlemaker (talk) 04:46, 8 March 2020 (UTC)Reply

Recent 2019 benchmarks appear to show that gc has improved more quickly than gccgo has (probably because it's received more attention), so even though gccgo has made significant improvements, gc seems like the better choice in most circumstances: https://meltware.com/2019/01/16/gccgo-benchmarks-2019.html Skyfaller (talk) 12:52, 11 April 2020 (UTC)Reply

Fish shell: Empty GOBIN causes '.' added to PATH (security/AUR build issue)

Hi there, noob here so bare with me ;-)

Section 1.3 recommends adding the Go binary directories to PATH.

For Fish shell users, this seems to cause an issue when GOBIN is not explicitly set (the default). In that case, go env GOBIN returns an empty string, which fish_add_path resolves to . (current directory) via realpath.

Result: Many AUR packages refuse to build when . is in PATH (error: "find: The current directory is included in the PATH environment variable, which is insecure...")

Should we warn Fish shell users to check if the value is non-empty before adding?

This worked for me:

set -l gobin (go env GOBIN)
if test -n "$gobin"
    fish_add_path --global --path --append $gobin
end

set -l gopath (go env GOPATH)
if test -n "$gopath"
    fish_add_path --global --path --append "$gopath/bin"
end

Hope that helps :-) Obradinn (talk) 07:51, 20 May 2026 (UTC)Reply