Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade to go 1.20 #5217

Merged
merged 6 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Setup Golang environment
uses: actions/setup-go@v4
with:
go-version: '^1.19'
go-version-file: 'backend/go.mod'
cache-dependency-path: '**/go.sum'

- name: Login to Docker Hub
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
fetch-depth: 2
- uses: actions/setup-go@v4
with:
go-version: '1.19'
go-version-file: 'backend/go.mod'
- name: Run tests
run: cd sdk/highlight-go && go test -race -covermode=atomic -coverprofile=coverage.out --v
16 changes: 2 additions & 14 deletions backend/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,19 @@ linters:

# all available settings of specific linters
linters-settings:
gosimple:
go: '1.19'

staticcheck:
go: '1.19'
checks: ['all']

stylecheck:
go: '1.19'

unused:
go: '1.19'

exhaustruct:
include:
- 'backend/alerts'

depguard:
list-type: blacklist
list-type: denylist
include-go-root: true
packages:
- errors
- log

packages-with-error-message:
# specify an error message to output when a blacklisted package is used
- errors: 'error handling is allowed only by github.com/pkg/errors'
# specify an error message to output when a denylist package is used
- log: 'logging is allowed only by github.com/sirupsen/logrus'
4 changes: 2 additions & 2 deletions backend/alerts/integrations/discord/discord.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package discord

import (
"errors"
"os"

"github.com/bwmarrin/discordgo"
"github.com/pkg/errors"
)

type Bot struct {
Expand All @@ -24,7 +24,7 @@ func NewDiscordBot(guildId string) (*Bot, error) {
session, err := discordgo.New("Bot " + DiscordBotSecret)

if err != nil {
return nil, errors.Wrap(err, "error creating Discord session")
return nil, errors.Join(err, errors.New("error creating Discord session"))
Vadman97 marked this conversation as resolved.
Show resolved Hide resolved
}

return &Bot{
Expand Down
2 changes: 1 addition & 1 deletion backend/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions backend/kafka-queue/kafkaqueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package kafka_queue

import (
"context"
cryptorand "crypto/rand"
"fmt"
"math/rand"
"sync"
Expand All @@ -24,7 +25,7 @@ func BenchmarkQueue_Submit(b *testing.B) {
log.SetLevel(log.DebugLevel)
log.WithContext(ctx).Infof("Starting benchmark")

rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))

writer := New(ctx, "dev", Producer)
reader := New(ctx, "dev", Consumer)
Expand All @@ -40,8 +41,12 @@ func BenchmarkQueue_Submit(b *testing.B) {
go func(w int) {
dataBytes := make([]byte, msgSizeBytes)
for j := 0; j < submitsPerWorker; j++ {
rand.Read(dataBytes)
err := writer.Submit(ctx, &Message{
_, err := cryptorand.Read(dataBytes)
if err != nil {
log.WithContext(ctx).Error(err)
}

err = writer.Submit(ctx, &Message{
Type: PushPayload,
PushPayload: &PushPayloadArgs{
Events: model.ReplayEventsInput{
Expand Down
2 changes: 1 addition & 1 deletion backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func validateOrigin(_ *http.Request, origin string) bool {
var defaultPort = "8082"

func main() {
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))
ctx := context.TODO()

// setup highlight
Expand Down
4 changes: 2 additions & 2 deletions backend/private-graph/graph/schema.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4832,7 +4832,7 @@ func (r *queryResolver) DailyErrorFrequency(ctx context.Context, projectID int,

if projectID == 0 {
// Make error distribution random for demo org so it looks pretty
rand.Seed(int64(errGroup.ID))
rand.New(rand.NewSource(int64(errGroup.ID)))
var dists []int64
for i := 0; i <= dateOffset; i++ {
t := int64(rand.Intn(10) + 1)
Expand All @@ -4856,7 +4856,7 @@ func (r *queryResolver) ErrorDistribution(ctx context.Context, projectID int, er

if projectID == 0 {
// Make error distribution random for demo org so it looks pretty
rand.Seed(int64(errGroup.ID))
rand.New(rand.NewSource(int64(errGroup.ID)))
dists := []*modelInputs.ErrorDistributionItem{}
for i := 0; i <= 3; i++ {
t := int64(rand.Intn(10) + 1)
Expand Down
2 changes: 1 addition & 1 deletion backend/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ func (w *Worker) Start(ctx context.Context) {
sessionsSpan.Finish()
continue
}
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))
rand.Shuffle(len(sessions), func(i, j int) {
sessions[i], sessions[j] = sessions[j], sessions[i]
})
Expand Down
2 changes: 1 addition & 1 deletion e2e/go/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.19
go 1.20

use ./backend

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { QuickStartStep } from '../QuickstartContent'
export const dependencies: QuickStartStep = {
title: 'Prerequisites',
content:
'Before we get started, you should install [Go](https://go.dev/) (1.19) and [Node.js](https://nodejs.org/en) (18).' +
'Before we get started, you should install [Go](https://go.dev/) (1.20) and [Node.js](https://nodejs.org/en) (18).' +
'You should have the latest version of [Docker](https://docs.docker.com/engine/install/) (19.03.0+) ' +
'and [Git](https://git-scm.com/downloads) (2.13+) installed. ' +
'For a local deploy, we suggest [configuring docker](https://docs.docker.com/desktop/settings/mac/#resources) ' +
'to use at least 8GB of RAM, 4 CPUs, and 64 GB of disk space.',
code: {
language: 'bash',
text: `$ go version
go version go1.19.3 darwin/arm64
go version go1.20.3 darwin/arm64
$ node --version
v18.15.0`,
},
Expand Down
10 changes: 0 additions & 10 deletions sdk/highlight-go/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,5 @@ linters:

# all available settings of specific linters
linters-settings:
gosimple:
go: '1.19'

staticcheck:
go: '1.19'
checks: ['all']

stylecheck:
go: '1.19'

unused:
go: '1.19'
2 changes: 1 addition & 1 deletion sdk/highlight-go/go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.