Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

dev-lang/go: slotting

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
1 post • Page 1 of 1
Author
Message
oz_tiram
n00b
n00b
Posts: 49
Joined: Sun May 31, 2015 12:24 pm

dev-lang/go: slotting

  • Quote

Post by oz_tiram » Mon Mar 30, 2026 7:28 pm

I found my self longing for this feature for quite sometime. While not really necessary to have like with dynamic language it's a nice thing to have.
In python\ruby world you might need different run times to run a program. With go that's usually isn't the case. A package built with go-1.24 will even run after you remove dev-lang/go.

But ... sometimes some external software will require a golang version which isn't currently available on my gentoo. Since I work a lot for customers with outdate go versions, the solution was always to use goenv\mise\asdf.
I tried all, and each has it's own quirks. If you are ready to try another solution with it's own quirks, keep on reading.

The solution - as the title says - is using go-lang slots. There has been an open issue for quite some time now (https://bugs.gentoo.org/941769), but it's been dormant, so I decided to give it a shot.

Using eselect and gentoo is very convenient for me (as I also do a lot of work with python and always really on gentoo to provide all the python versions I need).

If you want to have multiple versions of go in gentoo, here is what you can dot:

Code: Select all

$ cat /etc/portage/repos.conf/golang-overlay.conf 
[golang-overlay]
location = /var/db/repos/golang-overlay
masters = gentoo
sync-type = git
sync-uri = https://gitlab.com/oz123/golang-overlay.git
auto-sync = yes

Now, run emerge sync ...

Code: Select all

 sudo emerge --sync golang-overlay
>>> Syncing repository 'golang-overlay' into '/var/db/repos/golang-overlay'...
/usr/sbin/git clone --depth 1 https://gitlab.com/oz123/golang-overlay.git .
Cloning into '.'...
remote: Enumerating objects: 31, done.
remote: Counting objects: 100% (31/31), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 31 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (31/31), 17.41 KiB | 8.71 MiB/s, done.
Resolving deltas: 100% (2/2), done.
=== Sync completed for golang-overlay

Action: sync for repo: golang-overlay, returned code = 0


And remove gentoo's unslotted go:

Code: Select all

sudo emerge -C dev-lang/go
And install a slotted version:

Code: Select all

$ sudo emerge -a go:1.25

These are the packages that would be merged, in order:

Calculating dependencies... done!
Dependency resolution took 2.25 s (backtrack: 0/20).

[ebuild  N     ] dev-lang/go-1.25.8  CPU_FLAGS_X86="sse2" 

Would you like to merge these packages? [Yes/No] 

Now you should see:

Code: Select all

$ sudo eselect go list
Available Go versions:
  [1]   1.25 *
You can also install 1.24 and 1.26 from this overlay:

Code: Select all


└ $ sudo emerge -akg go:1.24
...

These are the packages that would be merged, in order:

Calculating dependencies... done!
Dependency resolution took 3.72 s (backtrack: 0/20).

[binary  NS   ~] dev-lang/go-1.24.12-r1-1 [1.25.8]

Would you like to merge these packages? [Yes/No] 

>>> Emerging binary (1 of 1) dev-lang/go-1.24.12-r1::golang-overlay
 * go-1.24.12-r1-2.gpkg.tar MD5 SHA1 size ;-) ...                        [ ok ]
>>> Extracting info
>>> Extracting dev-lang/go-1.24.12-r1

>>> Installing (1 of 1) dev-lang/go-1.24.12-r1::golang-overlay
Go 1.25 is already active. Nothing to do.

>>> Recording dev-lang/go in "world" favorites file...

>>> Completed (1 of 1) dev-lang/go-1.24.12-r1::golang-overlay

 * GNU info directory index is up-to-date.                                                                                                                                                                                                                                                                                  | 17:04:37
└ $ sudo eselect go list
Available Go versions:
  [1]   1.24
  [2]   1.25 *

All existing ebuilds in main gentoo repo will work:

Code: Select all

$ sudo eselect go list
Available Go versions:
  [1]   1.24
  [2]   1.25 *
If you try installing caddy for example it will fail when you set the wrong go version:

Code: Select all

$ sudo eselect go set 1 
Successfully switched to Go 1.24

$ sudo emerge  caddy
Calculating dependencies... done!
Dependency resolution took 2.31 s (backtrack: 0/20).


>>> Verifying ebuild manifests

>>> Emerging (1 of 1) www-servers/caddy-2.10.2-r1::gentoo
 * caddy-2.10.2.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                                                                                                                                                                                                             [ ok ]
 * caddy-2.10.2-r1-deps.tar.xz BLAKE2B SHA512 size ;-) ...                                                                                                                                                                                                                                                                                     [ ok ]
 * caddy-2.10.2-r1-go-mod-sum.patch BLAKE2B SHA512 size ;-) ...                                                                                                                                                                                                                                                                                [ ok ]
 * caddy-2.10.2-docs.tar.gz BLAKE2B SHA512 size ;-) ...                                                                                                                                                                                                                                                                                        [ ok ]
>>> Unpacking source...
>>> Unpacking 'caddy-2.10.2.tar.gz' to /var/tmp/portage/www-servers/caddy-2.10.2-r1/work
>>> Unpacking 'caddy-2.10.2-r1-deps.tar.xz' to /var/tmp/portage/www-servers/caddy-2.10.2-r1/work
=== Skipping unpack of 'caddy-2.10.2-r1-go-mod-sum.patch'
>>> Unpacking 'caddy-2.10.2-docs.tar.gz' to /var/tmp/portage/www-servers/caddy-2.10.2-r1/work
>>> Source unpacked in /var/tmp/portage/www-servers/caddy-2.10.2-r1/work
>>> Preparing source in /var/tmp/portage/www-servers/caddy-2.10.2-r1/work/caddy-2.10.2 ...
 * Applying caddy-2.10.2-r1-go-mod-sum.patch ...                                                                                                                                                                                                                                                                                               [ ok ]
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/www-servers/caddy-2.10.2-r1/work/caddy-2.10.2 ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/www-servers/caddy-2.10.2-r1/work/caddy-2.10.2 ...
go build -ldflags -X github.com/caddyserver/caddy/v2.CustomVersion=2.10.2 ./cmd/caddy
WORK=/var/tmp/portage/www-servers/caddy-2.10.2-r1/temp/go-build2297694948
go: go.mod requires go >= 1.25.1 (running go 1.24.12; GOTOOLCHAIN=local)
 * ERROR: www-servers/caddy-2.10.2-r1::gentoo failed (compile phase):
 *   go build -ldflags -X github.com/caddyserver/caddy/v2.CustomVersion=2.10.2 ./cmd/caddy failed
 * 
 * Call stack:
 *     ebuild.sh, line  143:  Called src_compile
 *   environment, line 1472:  Called ego 'build' '-ldflags' '-X github.com/caddyserver/caddy/v2.CustomVersion=2.10.2' './cmd/caddy'
 *   environment, line  755:  Called die
 * The specific snippet of code:
 *       "$@" || die -n "${*} failed"
 * 
 * If you need support, post the output of `emerge --info '=www-servers/caddy-2.10.2-r1::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=www-servers/caddy-2.10.2-r1::gentoo'`.
 * The complete build log is located at '/var/log/portage/www-servers:caddy-2.10.2-r1:20260330-150610.log'.
 * For convenience, a symlink to the build log is located at '/var/tmp/portage/www-servers/caddy-2.10.2-r1/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/www-servers/caddy-2.10.2-r1/temp/environment'.
 * Working directory: '/var/tmp/portage/www-servers/caddy-2.10.2-r1/work/caddy-2.10.2'
 * S: '/var/tmp/portage/www-servers/caddy-2.10.2-r1/work/caddy-2.10.2'

>>> Failed to emerge www-servers/caddy-2.10.2-r1, Log file:

>>>  '/var/log/portage/www-servers:caddy-2.10.2-r1:20260330-150610.log'
Set it back to go 1.25 and compile again:

Code: Select all

$ sudo eselect go set 2
Successfully switched to Go 1.25
$ sudo emerge  -q caddy
>>> Verifying ebuild manifests
>>> Emerging (1 of 1) www-servers/caddy-2.10.2-r1::gentoo
>>> Installing (1 of 1) www-servers/caddy-2.10.2-r1::gentoo
>>> Recording www-servers/caddy in "world" favorites file...
>>> Completed (1 of 1) www-servers/caddy-2.10.2-r1::gentoo
That's it. Now I, and you too, can use the tools we love and know for long time.

The overlay has golang versions 1.21 to 1.26.
I will continue adding versions as needed (or requested).
Hopefully, a kind maintainer can continue this job in gentoo upstream.
I'll be happy to help too.

Feedback, issues and suggestions are welcome.
Top
Post Reply
1 post • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy