GA

2024/09/10

今更 素のCentOS7.9でGoを新しくせずにdlvを入れたい

古いところに新しいGoとか入れずにdlvだけ使いたかった。


$ cat /etc/centos-release

CentOS Linux release 7.9.2009 (Core)

$ rpm -q golang
golang-1.18.4-1.el7.x86_64

$ go version

go version go1.18.4 linux/amd64

delve/Documentation/installation at master · go-delve/delve の手順におとなしく従うとgoのバージョンが古いって怒られるので

$ git clone https://github.com/go-delve/delve
Cloning into 'delve'...
remote: Enumerating objects: 28504, done.
remote: Counting objects: 100% (175/175), done.
remote: Compressing objects: 100% (111/111), done.
remote: Total 28504 (delta 83), reused 143 (delta 61), pack-reused 28329 (from 1)
Receiving objects: 100% (28504/28504), 31.27 MiB | 16.54 MiB/s, done.
Resolving deltas: 100% (19460/19460), done.
Checking connectivity... done.

$ cd delve/

$ go install github.com/go-delve/delve/cmd/dlv
# github.com/go-delve/delve/pkg/proc/gdbserial
pkg/proc/gdbserial/rr.go:247:35: undefined: strings.CutPrefix
pkg/proc/gdbserial/rr.go:248:33: undefined: strings.CutPrefix
note: module requires Go 1.21

golang-1.18-4がリリースされたころdlvのタグを探して

$ git checkout v1.20.0
Note: checking out 'v1.20.0'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at f07be48... *: CHANGELOG and bump to version 1.20.0 (#3209)

$ go install github.com/go-delve/delve/cmd/dlv

エラーは出ない。

$ env | grep GO
GOPATH=/home/yoku0825/go

$ ll /home/yoku0825/go/bin/dlv
-rwxr-xr-x 1 yoku0825 yoku0825 17370208 Sep 10 14:21 /home/yoku0825/go/bin/dlv

入った。

0 件のコメント :

コメントを投稿