Skip to content

Commit

Permalink
Upgrade to Go 1.21 (#7843)
Browse files Browse the repository at this point in the history
  • Loading branch information
samcoe committed Aug 16, 2023
1 parent e4cddb5 commit 4a57a81
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Please avoid:
## Building the project

Prerequisites:
- Go 1.19+
- Go 1.21+

Build with:
* Unix-like systems: `make`
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Deployment

concurrency:
concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

Expand All @@ -17,7 +17,7 @@ on:
default: production
type: environment
go_version:
default: "1.19"
default: "1.21"
type: string
platforms:
default: "linux,macos,windows"
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
dist/*.tar.gz
dist/*.rpm
dist/*.deb
macos:
runs-on: macos-latest
environment: ${{ inputs.environment }}
Expand Down Expand Up @@ -118,7 +118,7 @@ jobs:
path: |
dist/*.tar.gz
dist/*.zip
windows:
runs-on: windows-latest
environment: ${{ inputs.environment }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21

- name: Check out code
uses: actions/checkout@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Set up Go 1.19
- name: Set up Go 1.21
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21

- name: Check out code
uses: actions/checkout@v3
Expand All @@ -40,7 +40,7 @@ jobs:
go mod verify
go mod download
LINT_VERSION=1.50.1
LINT_VERSION=1.54.1
curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v${LINT_VERSION}/golangci-lint-${LINT_VERSION}-linux-amd64.tar.gz | \
tar xz --strip-components 1 --wildcards \*/golangci-lint
mkdir -p bin && mv golangci-lint bin/
Expand Down
2 changes: 1 addition & 1 deletion docs/source.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Installation from source

1. Verify that you have Go 1.19+ installed
1. Verify that you have Go 1.21+ installed

```sh
$ go version
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/cli/cli/v2

go 1.19
go 1.21

require (
github.com/AlecAivazis/survey/v2 v2.3.7
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwA
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
Expand Down Expand Up @@ -182,6 +183,7 @@ golang.org/x/net v0.0.0-20220923203811-8be639271d50/go.mod h1:YDH+HFinaLZZlnHAfS
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M=
golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -221,11 +223,13 @@ golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM=
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f h1:BWUVssLB0HVOSY78gIdvk1dTVYtT1y8SBWtPYuTJ/6w=
google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
Expand Down
6 changes: 6 additions & 0 deletions internal/codespaces/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func createHttpClient() (*http.Client, error) {

func TestNew_APIURL_dotcomConfig(t *testing.T) {
t.Setenv("GITHUB_API_URL", "")
t.Setenv("GITHUB_SERVER_URL", "https://github.com")
cfg := &config.ConfigMock{
AuthenticationFunc: func() *config.AuthConfig {
return &config.AuthConfig{}
Expand All @@ -158,6 +159,7 @@ func TestNew_APIURL_dotcomConfig(t *testing.T) {

func TestNew_APIURL_customConfig(t *testing.T) {
t.Setenv("GITHUB_API_URL", "")
t.Setenv("GITHUB_SERVER_URL", "https://github.mycompany.com")
cfg := &config.ConfigMock{
AuthenticationFunc: func() *config.AuthConfig {
authCfg := &config.AuthConfig{}
Expand All @@ -182,6 +184,7 @@ func TestNew_APIURL_customConfig(t *testing.T) {

func TestNew_APIURL_env(t *testing.T) {
t.Setenv("GITHUB_API_URL", "https://api.mycompany.com")
t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com")
cfg := &config.ConfigMock{
AuthenticationFunc: func() *config.AuthConfig {
return &config.AuthConfig{}
Expand Down Expand Up @@ -218,6 +221,7 @@ func TestNew_APIURL_dotcomFallback(t *testing.T) {

func TestNew_ServerURL_dotcomConfig(t *testing.T) {
t.Setenv("GITHUB_SERVER_URL", "")
t.Setenv("GITHUB_API_URL", "https://api.github.com")
cfg := &config.ConfigMock{
AuthenticationFunc: func() *config.AuthConfig {
return &config.AuthConfig{}
Expand All @@ -240,6 +244,7 @@ func TestNew_ServerURL_dotcomConfig(t *testing.T) {

func TestNew_ServerURL_customConfig(t *testing.T) {
t.Setenv("GITHUB_SERVER_URL", "")
t.Setenv("GITHUB_API_URL", "https://github.mycompany.com/api/v3")
cfg := &config.ConfigMock{
AuthenticationFunc: func() *config.AuthConfig {
authCfg := &config.AuthConfig{}
Expand All @@ -264,6 +269,7 @@ func TestNew_ServerURL_customConfig(t *testing.T) {

func TestNew_ServerURL_env(t *testing.T) {
t.Setenv("GITHUB_SERVER_URL", "https://mycompany.com")
t.Setenv("GITHUB_API_URL", "https://api.mycompany.com")
cfg := &config.ConfigMock{
AuthenticationFunc: func() *config.AuthConfig {
return &config.AuthConfig{}
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/label/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ func createRun(opts *createOptions) error {
}

if opts.Color == "" {
rand.Seed(time.Now().UnixNano())
opts.Color = randomColors[rand.Intn(len(randomColors)-1)]
r := rand.New(rand.NewSource(time.Now().UnixNano()))
opts.Color = randomColors[r.Intn(len(randomColors)-1)]
}

opts.IO.StartProgressIndicator()
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/repo/credits/credits.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func creditsRun(opts *CreditsOptions) error {
return nil
}

rand.Seed(time.Now().UnixNano())
r := rand.New(rand.NewSource(time.Now().UnixNano()))

lines := []string{}

Expand All @@ -199,13 +199,13 @@ func creditsRun(opts *CreditsOptions) error {

starLinesLeft := []string{}
for x := 0; x < len(lines); x++ {
starLinesLeft = append(starLinesLeft, starLine(margin))
starLinesLeft = append(starLinesLeft, starLine(r, margin))
}

starLinesRight := []string{}
for x := 0; x < len(lines); x++ {
lineWidth := termWidth - (margin + len(lines[x]))
starLinesRight = append(starLinesRight, starLine(lineWidth))
starLinesRight = append(starLinesRight, starLine(r, lineWidth))
}

loop := true
Expand Down Expand Up @@ -245,13 +245,13 @@ func creditsRun(opts *CreditsOptions) error {
return nil
}

func starLine(width int) string {
func starLine(r *rand.Rand, width int) string {
line := ""
starChance := 0.1
for y := 0; y < width; y++ {
chance := rand.Float64()
chance := r.Float64()
if chance <= starChance {
charRoll := rand.Float64()
charRoll := r.Float64()
switch {
case charRoll < 0.3:
line += "."
Expand Down
12 changes: 6 additions & 6 deletions pkg/cmd/repo/garden/garden.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func gardenRun(opts *GardenOptions) error {
}

seed := computeSeed(ghrepo.FullName(toView))
rand.Seed(seed)
r := rand.New(rand.NewSource(seed))

termWidth, termHeight, err := utils.TerminalSize(out)
if err != nil {
Expand Down Expand Up @@ -198,7 +198,7 @@ func gardenRun(opts *GardenOptions) error {
}
player := &Player{0, 0, cs.Bold("@"), geo, 0}

garden := plantGarden(commits, geo)
garden := plantGarden(r, commits, geo)
if len(garden) < geo.Height {
geo.Height = len(garden)
}
Expand Down Expand Up @@ -334,11 +334,11 @@ func isQuit(b []byte) bool {
return rune(b[0]) == 'q' || bytes.Equal(b, ctrlC)
}

func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell {
func plantGarden(r *rand.Rand, commits []*Commit, geo *Geometry) [][]*Cell {
cellIx := 0
grassCell := &Cell{RGB(0, 200, 0, ","), "You're standing on a patch of grass in a field of wildflowers."}
garden := [][]*Cell{}
streamIx := rand.Intn(geo.Width - 1)
streamIx := r.Intn(geo.Width - 1)
if streamIx == geo.Width/2 {
streamIx--
}
Expand All @@ -363,7 +363,7 @@ func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell {
})
tint += 15
streamIx--
if rand.Float64() < 0.5 {
if r.Float64() < 0.5 {
streamIx++
}
if streamIx < 0 {
Expand Down Expand Up @@ -393,7 +393,7 @@ func plantGarden(commits []*Commit, geo *Geometry) [][]*Cell {
continue
}

chance := rand.Float64()
chance := r.Float64()
if chance <= geo.Density {
commit := commits[cellIx]
garden[y] = append(garden[y], &Cell{
Expand Down

0 comments on commit 4a57a81

Please sign in to comment.