gantsign / ansible-role-golang

Ansible role for installing the Go language SDK

Home Page:https://galaxy.ansible.com/gantsign/golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Role not replacing link on /usb/bin/

staticdev opened this issue · comments

After installing in a new Debian 11, which go version returns 1.15 with golang_version: '1.18'.

Go was correctly installed in the folder, but symlink is not checked.

I wanted to do a PR but not sure how to debug this verify step on IDE though.

I wanted to add a verify test to assert ${golang_version} in cmd.output and try to reproduce: https://github.com/gantsign/ansible-role-golang/blob/master/molecule/default/tests/test_role.py#L17

Hi @staticdev, thanks for reporting this issue.

There are two things at play here. Firstly, this role doesn't work by changing the symbolic links, it works by changing the PATH environment variable. Both approaches have pros and cons, but I generally favor changing the PATH when there's more than one executable. Secondly, there's the precedence of the Go installation in the PATH, it was added to the end of the PATH (lowest precedence). I've released version 3.0.0 of this role, which now adds this to the start of the PATH (highest precedence), so it should override the Go installed as an OS package.

For this to work /etc/profile.d/golang.sh needs to be sourced by your shell, this is normally sourced indirectly by sourcing /etc/profile. If you're using Go from an interactive shell /etc/profile will probably be sourced for you by the standard initialization scripts.

Thanks for the explanation @freemanjp, I will try version 3.0.0 then ;)

It is ok, I see it works so closing this.