Skip to content

Commit

Permalink
MM-49703: Bump to Go 1.19 (mattermost-community#4489)
Browse files Browse the repository at this point in the history
* MM-49703: Bump to Go 1.19

Also fix some gofmt issues

https://mattermost.atlassian.net/browse/MM-49703

* Bump versions in go.mod

* Update go.work as well

* Bump GolangCI to 1.50.1

* Upgraded to new builder image
  • Loading branch information
agnivade authored Jan 20, 2023
1 parent 23e7cf0 commit 2d0dde2
Show file tree
Hide file tree
Showing 34 changed files with 65 additions and 62 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: "Test server: ${{matrix['db']}}"
run: cd focalboard; make server-test-${{matrix['db']}}
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -137,7 +137,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: "Test server (minimum): ${{matrix['db']}}"
run: cd focalboard; make server-test-mini-${{matrix['db']}}
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: "Test server (minimum): ${{matrix['db']}}"
run: cd focalboard; make server-test-mini-${{matrix['db']}}
8 changes: 4 additions & 4 deletions .github/workflows/dev-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -129,7 +129,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: List Xcode versions
run: ls -n /Applications/ | grep Xcode*
Expand Down Expand Up @@ -190,7 +190,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: Setup NuGet
uses: nuget/setup-nuget@v1
Expand Down Expand Up @@ -258,7 +258,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: Set up Node
uses: actions/setup-node@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5
- uses: actions/checkout@v3
with:
path: "focalboard"
Expand All @@ -50,7 +50,7 @@ jobs:
path: "mattermost-server"
ref : "master"
- name: set up golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.46.2
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.1
- name: lint
run: |
cd focalboard
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/prod-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: Setup Node
uses: actions/setup-node@v3
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: List Xcode versions
run: ls -n /Applications/ | grep Xcode*
Expand Down Expand Up @@ -188,7 +188,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: Setup NuGet
uses: nuget/setup-nuget@v1
Expand Down Expand Up @@ -257,7 +257,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18.1
go-version: 1.19.5

- name: Set up Node
uses: actions/setup-node@v3
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ stages:

variables:
BUILD: "yes"
IMAGE_BUILDER: $CI_REGISTRY/mattermost/ci/images/builder:go-1.18.1-node-16.15.0-1
IMAGE_BUILDER: $CI_REGISTRY/mattermost/ci/images/builder:go-1.19.5-node-16.15.0-1

include:
- project: mattermost/ci/focalboard
Expand Down
2 changes: 1 addition & 1 deletion build/gowork/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func makeGoWork(ci bool) string {

var b strings.Builder

b.WriteString("go 1.18\n\n")
b.WriteString("go 1.19\n\n")
b.WriteString("use ./server\n")

for repo, envVarName := range repos {
Expand Down
2 changes: 1 addition & 1 deletion linux/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mattermost/focalboard/linux

go 1.18
go 1.19

replace github.com/mattermost/focalboard/server => ../server

Expand Down
2 changes: 1 addition & 1 deletion mattermost-plugin/build/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mattermost/mattermost-plugin-starter-template/build

go 1.18
go 1.19

require (
github.com/go-git/go-git/v5 v5.1.0
Expand Down
2 changes: 1 addition & 1 deletion mattermost-plugin/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mattermost/focalboard/mattermost-plugin

go 1.18
go 1.19

require (
github.com/golang/mock v1.6.0
Expand Down
3 changes: 0 additions & 3 deletions server/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@ linters:
enable:
- gofmt
- goimports
- deadcode
- ineffassign
- structcheck
- varcheck
- unparam
- errcheck
- govet
Expand Down
4 changes: 2 additions & 2 deletions server/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func stringResponse(w http.ResponseWriter, message string) {
_, _ = fmt.Fprint(w, message)
}

func jsonStringResponse(w http.ResponseWriter, code int, message string) {
func jsonStringResponse(w http.ResponseWriter, code int, message string) { //nolint:unparam
setResponseHeader(w, "Content-Type", "application/json")
w.WriteHeader(code)
fmt.Fprint(w, message)
Expand All @@ -232,7 +232,7 @@ func jsonBytesResponse(w http.ResponseWriter, code int, json []byte) {
_, _ = w.Write(json)
}

func setResponseHeader(w http.ResponseWriter, key string, value string) {
func setResponseHeader(w http.ResponseWriter, key string, value string) { //nolint:unparam
header := w.Header()
if header == nil {
return
Expand Down
2 changes: 1 addition & 1 deletion server/api/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// makeAuditRecord creates an audit record pre-populated with data from the request.
func (a *API) makeAuditRecord(r *http.Request, event string, initialStatus string) *audit.Record {
func (a *API) makeAuditRecord(r *http.Request, event string, initialStatus string) *audit.Record { //nolint:unparam
ctx := r.Context()
var sessionID string
var userID string
Expand Down
5 changes: 3 additions & 2 deletions server/api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,13 @@ func (a *API) attachSession(handler func(w http.ResponseWriter, r *http.Request)

authService := session.AuthService
if authService != a.authService {
a.logger.Error(`Session authService mismatch`,
msg := `Session authService mismatch`
a.logger.Error(msg,
mlog.String("sessionID", session.ID),
mlog.String("want", a.authService),
mlog.String("got", authService),
)
a.errorResponse(w, r, model.NewErrUnauthorized(err.Error()))
a.errorResponse(w, r, model.NewErrUnauthorized(msg))
return
}

Expand Down
2 changes: 1 addition & 1 deletion server/api/members.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (a *API) handleAddMember(w http.ResponseWriter, r *http.Request) {
}

if reqBoardMember.UserID == "" {
a.errorResponse(w, r, model.NewErrBadRequest(err.Error()))
a.errorResponse(w, r, model.NewErrBadRequest("empty userID"))
return
}

Expand Down
2 changes: 1 addition & 1 deletion server/app/insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (a *App) GetTeamBoardsInsights(userID string, teamID string, opts *mmModel.
if err != nil {
return nil, err
}
return a.store.GetTeamBoardsInsights(teamID, userID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage, boardIDs)
return a.store.GetTeamBoardsInsights(teamID, opts.StartUnixMilli, opts.Page*opts.PerPage, opts.PerPage, boardIDs)
}

func (a *App) GetUserBoardsInsights(userID string, teamID string, opts *mmModel.InsightsOpts) (*model.BoardInsightsList, error) {
Expand Down
4 changes: 2 additions & 2 deletions server/app/insights_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestGetTeamAndUserBoardsInsights(t *testing.T) {
th.Store.EXPECT().GetUserByID("user-id").Return(fakeUser, nil).AnyTimes()
th.Store.EXPECT().GetBoardsForUserAndTeam("user-id", "team-id", true).Return(mockInsightsBoards, nil).AnyTimes()
th.Store.EXPECT().
GetTeamBoardsInsights("team-id", "user-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}).
GetTeamBoardsInsights("team-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}).
Return(mockTeamInsightsList, nil)
results, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10})
require.NoError(t, err)
Expand All @@ -74,7 +74,7 @@ func TestGetTeamAndUserBoardsInsights(t *testing.T) {
th.Store.EXPECT().GetUserByID("user-id").Return(fakeUser, nil).AnyTimes()
th.Store.EXPECT().GetBoardsForUserAndTeam("user-id", "team-id", true).Return(mockInsightsBoards, nil).AnyTimes()
th.Store.EXPECT().
GetTeamBoardsInsights("team-id", "user-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}).
GetTeamBoardsInsights("team-id", int64(0), 0, 10, []string{"mock-user-workspace-id"}).
Return(nil, insightError{"board-insight-error"})
_, err := th.App.GetTeamBoardsInsights("user-id", "team-id", &mmModel.InsightsOpts{StartUnixMilli: 0, Page: 0, PerPage: 10})
require.Error(t, err)
Expand Down
1 change: 1 addition & 0 deletions server/assets/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import (
// DefaultTemplatesArchive is an embedded archive file containing the default
// templates to be imported to team 0.
// This archive is generated with `make templates-archive`
//
//go:embed templates.boardarchive
var DefaultTemplatesArchive []byte
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mattermost/focalboard/server

go 1.18
go 1.19

require (
github.com/Masterminds/squirrel v1.5.3
Expand Down
2 changes: 1 addition & 1 deletion server/go.tools.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/mattermost/focalboard/server

go 1.18
go 1.19

require github.com/golang/mock v1.6.0

Expand Down
2 changes: 0 additions & 2 deletions server/integrationtests/cards_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,7 @@ func TestGetCard(t *testing.T) {
})
}

//
// Helpers.
//
func reverse(src []string) []string {
out := make([]string, 0, len(src))
for i := len(src) - 1; i >= 0; i-- {
Expand Down
4 changes: 3 additions & 1 deletion server/main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func main() {
if pDBConfig != nil && len(*pDBConfig) > 0 {
config.DBConfigString = *pDBConfig
// Don't echo, as the confix string may contain passwords
logger.Info("DBConfigString overriden from commandline")
logger.Info("DBConfigString overridden from commandline")
}

if pPort != nil && *pPort > 0 && *pPort != config.Port {
Expand Down Expand Up @@ -166,6 +166,7 @@ func main() {
}

// StartServer starts the server
//
//export StartServer
func StartServer(webPath *C.char, filesPath *C.char, port int, singleUserToken, dbConfigString, configFilePath *C.char) {
startServer(
Expand All @@ -179,6 +180,7 @@ func StartServer(webPath *C.char, filesPath *C.char, port int, singleUserToken,
}

// StopServer stops the server
//
//export StopServer
func StopServer() {
stopServer()
Expand Down
2 changes: 1 addition & 1 deletion server/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ func (s *Server) UpdateAppConfig() {
// Local server

func (s *Server) startLocalModeServer() error {
s.localModeServer = &http.Server{
s.localModeServer = &http.Server{ //nolint:gosec
Handler: s.localRouter,
ConnContext: api.SetContextConn,
}
Expand Down
8 changes: 5 additions & 3 deletions server/services/audit/audit.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ func NewAudit(options ...mlog.Option) (*Audit, error) {

// Configure provides a new configuration for this audit service.
// Zero or more sources of config can be provided:
// cfgFile - path to file containing JSON
// cfgEscaped - JSON string probably from ENV var
//
// cfgFile - path to file containing JSON
// cfgEscaped - JSON string probably from ENV var
//
// For each case JSON containing log targets is provided. Target name collisions are resolved
// using the following precedence:
// cfgFile > cfgEscaped
//
// cfgFile > cfgEscaped
func (a *Audit) Configure(cfgFile string, cfgEscaped string) error {
return a.auditLogger.Configure(cfgFile, cfgEscaped, nil)
}
Expand Down
2 changes: 1 addition & 1 deletion server/services/metrics/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Service struct {
// NewMetricsServer factory method to create a new prometheus server.
func NewMetricsServer(address string, metricsService *Metrics, logger mlog.LoggerIFace) *Service {
return &Service{
&http.Server{
&http.Server{ //nolint:gosec
Addr: address,
Handler: promhttp.HandlerFor(metricsService.registry, promhttp.HandlerOpts{
ErrorLog: logger.StdLogger(mlog.LvlError),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ func (s *MattermostAuthLayer) GetLicense() *mmModel.License {
return s.servicesAPI.GetLicense()
}

func boardFields(prefix string) []string {
func boardFields(prefix string) []string { //nolint:unparam
fields := []string{
"id",
"team_id",
Expand Down
8 changes: 4 additions & 4 deletions server/services/store/mockstore/mockstore.go

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

2 changes: 1 addition & 1 deletion server/services/store/sqlstore/board_insights.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/mattermost/mattermost-server/v6/shared/mlog"
)

func (s *SQLStore) getTeamBoardsInsights(db sq.BaseRunner, teamID string, userID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) {
func (s *SQLStore) getTeamBoardsInsights(db sq.BaseRunner, teamID string, since int64, offset int, limit int, boardIDs []string) (*model.BoardInsightsList, error) {
boardsHistoryQuery := s.getQueryBuilder(db).
Select("boards.id, boards.icon, boards.title, count(boards_history.id) as count, boards_history.modified_by, boards.created_by").
From(s.tablePrefix + "boards_history as boards_history").
Expand Down
Loading

0 comments on commit 2d0dde2

Please sign in to comment.