How to Compile TiUP Locally with Go 1.18? I Tried TiUP Versions from 1.12 to 1.16, All Require Go Version 1.19 or Above, but Our Compilation Environment Uses Go 1.18 Due to Dependencies on Other Components. How Can I Compile TiUP with Go 1.18?

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 想本地编译tiup,目前我试过从tiup1.12到tiup1.16,都要求go版本在1.19以上,但是我们的编译环境go版本是1.18,我们很多其他组件的编译需要依赖1.18版本的go,所以不能贸然升级go版本。想咨询一下,怎么使用1.18版本的go编译tiup呢?

| username: TiDBer_ohWoUM09

I want to compile tiup locally. I have tried versions from tiup1.12 to tiup1.16, all of which require go version 1.19 or above. However, our compilation environment uses go version 1.18, and many of our other components depend on go version 1.18 for compilation, so we cannot upgrade the go version rashly. I would like to ask, how can I use go version 1.18 to compile tiup?

| username: 有猫万事足 | Original post link

You can take a look at this PR, which upgrades the Go version of TiUP from 1.19 to 1.21. The modified files show how to set the Go version. You can revert this part and see if it can compile successfully.

| username: ShawnYan | Original post link

You can install multiple versions of Go locally, and then use the new version to compile TiUP.

| username: 呢莫不爱吃鱼 | Original post link

When using the go build command to compile a Go program, if you have multiple versions of the Go runtime in your environment, the compiler may use the runtime that matches the version of the go command. You can specify which version of Go to use by setting the GOPATH and GOROOT environment variables.

| username: 上官阳yang | Original post link

Thank you. Currently, we can accept using tiup version 1.10. If we need to upgrade the tiup version in the future, I will try to roll back this PR to see the effect.

| username: 上官阳yang | Original post link

Thank you. Currently, we can accept using tiup version 1.10 and compile with go1.18. If we need to upgrade the tiup version in the future, I will also try the suggestion of using multiple versions of go.

| username: 上官阳yang | Original post link

Multiple versions of Go are quite a suitable suggestion.