Bump Go version to 1.23.6 (#30242)
* Bump Go version to 1.23.6 * Update CodeQL Github action as well * Use server's Go version for CodeQL action Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com> * Empty commit to trigger CI * Bump golangci-lint to a version supporting Go 1.23 * Fix golangci-lint warnings Several rules from gosimple, revive and staticcheck linters were failing: - Redefinition of built-in identifiers (max, min, new, recover...) - Use of printf-like functions with simple strings - Check for nil slices, when len already takes it into account --------- Co-authored-by: Antonis Stamatiou <stamatiou.antonis@gmail.com> Co-authored-by: Mattermost Build <build@mattermost.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
77ae2e2d6d
Коммит
acbbd4c58d
2
.github/workflows/codeql-analysis.yml
поставляемый
2
.github/workflows/codeql-analysis.yml
поставляемый
@@ -42,7 +42,7 @@ jobs:
|
||||
- name: Setup go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.22'
|
||||
go-version-file: server/go.mod
|
||||
if: ${{ matrix.language == 'go' }}
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.22.6
|
||||
1.23.6
|
||||
|
||||
@@ -284,7 +284,7 @@ else
|
||||
endif
|
||||
|
||||
golangci-lint: ## Run golangci-lint on codebase
|
||||
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.1
|
||||
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.5
|
||||
|
||||
@echo Running golangci-lint
|
||||
$(GOBIN)/golangci-lint run ./...
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.22.6-bullseye@sha256:0838740c99e64dde1916553b004bdb1bc321823be83bde3d2a1563882eaab7e6
|
||||
FROM golang:1.23.6-bullseye@sha256:80eb3147ef40b58d527d9c2e634b1a79a750aee09de6f973844db38b33f0550b
|
||||
|
||||
RUN apt-get update && apt-get install -y make git apt-transport-https ca-certificates curl software-properties-common build-essential zip xmlsec1 jq pgloader
|
||||
|
||||
|
||||
@@ -284,8 +284,8 @@ func (a *App) MFARequired(rctx request.CTX) *model.AppError {
|
||||
return nil
|
||||
}
|
||||
|
||||
func checkUserLoginAttempts(user *model.User, max int) *model.AppError {
|
||||
if user.FailedAttempts >= max {
|
||||
func checkUserLoginAttempts(user *model.User, maxAttempts int) *model.AppError {
|
||||
if user.FailedAttempts >= maxAttempts {
|
||||
return model.NewAppError("checkUserLoginAttempts", "api.user.check_user_login_attempts.too_many.app_error", nil, "user_id="+user.Id, http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ const (
|
||||
passwordAllChars = passwordSpecialChars + passwordNumbers + passwordUpperCaseLetters + passwordLowerCaseLetters
|
||||
)
|
||||
|
||||
func randInt(max int) (int, error) {
|
||||
val, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
|
||||
func randInt(maxInt int) (int, error) {
|
||||
val, err := rand.Int(rand.Reader, big.NewInt(int64(maxInt)))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ func (a *App) buildFullPushNotificationMessage(c request.CTX, contentsConfig str
|
||||
}
|
||||
}
|
||||
|
||||
hasFiles := post.FileIds != nil && len(post.FileIds) > 0
|
||||
hasFiles := len(post.FileIds) > 0
|
||||
|
||||
msg.Message = a.getPushNotificationMessage(
|
||||
contentsConfig,
|
||||
|
||||
@@ -237,10 +237,10 @@ func (ch *Channels) initPlugins(c request.CTX, pluginDir, webappPluginDir string
|
||||
// Sync plugin active state when config changes. Also notify plugins.
|
||||
ch.pluginsLock.Lock()
|
||||
ch.RemoveConfigListener(ch.pluginConfigListenerID)
|
||||
ch.pluginConfigListenerID = ch.AddConfigListener(func(old, new *model.Config) {
|
||||
ch.pluginConfigListenerID = ch.AddConfigListener(func(oldCfg, newCfg *model.Config) {
|
||||
// If plugin status remains unchanged, only then run this.
|
||||
// Because (*App).InitPlugins is already run as a config change hook.
|
||||
if *old.PluginSettings.Enable == *new.PluginSettings.Enable {
|
||||
if *oldCfg.PluginSettings.Enable == *newCfg.PluginSettings.Enable {
|
||||
ch.syncPluginsActiveState()
|
||||
}
|
||||
|
||||
|
||||
@@ -232,19 +232,19 @@ func (a *App) BuildSamlMetadataObject(idpMetadata []byte) (*model.SamlMetadataRe
|
||||
data := &model.SamlMetadataResponse{}
|
||||
data.IdpDescriptorURL = entityDescriptor.EntityID
|
||||
|
||||
if entityDescriptor.IDPSSODescriptors == nil || len(entityDescriptor.IDPSSODescriptors) == 0 {
|
||||
if len(entityDescriptor.IDPSSODescriptors) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_idpssodescriptors.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
idpSSODescriptor := entityDescriptor.IDPSSODescriptors[0]
|
||||
if idpSSODescriptor.SingleSignOnServices == nil || len(idpSSODescriptor.SingleSignOnServices) == 0 {
|
||||
if len(idpSSODescriptor.SingleSignOnServices) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_ssoservices.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data.IdpURL = idpSSODescriptor.SingleSignOnServices[0].Location
|
||||
if idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors == nil || len(idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors) == 0 {
|
||||
if len(idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors) == 0 {
|
||||
err := model.NewAppError("BuildSamlMetadataObject", "api.admin.saml.invalid_xml_missing_keydescriptor.app_error", nil, "", http.StatusInternalServerError)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -463,9 +463,9 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
return s, nil
|
||||
}
|
||||
|
||||
s.platform.AddConfigListener(func(old, new *model.Config) {
|
||||
s.platform.AddConfigListener(func(oldCfg, newCfg *model.Config) {
|
||||
appInstance := New(ServerConnector(s.Channels()))
|
||||
if *old.GuestAccountsSettings.Enable && !*new.GuestAccountsSettings.Enable {
|
||||
if *oldCfg.GuestAccountsSettings.Enable && !*newCfg.GuestAccountsSettings.Enable {
|
||||
c := request.EmptyContext(s.Log())
|
||||
if appErr := appInstance.DeactivateGuests(c); appErr != nil {
|
||||
mlog.Error("Unable to deactivate guest accounts", mlog.Err(appErr))
|
||||
|
||||
@@ -180,13 +180,13 @@ func (ss *SqlStore) migrate(direction migrationDirection, dryRun bool) error {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Migrator) GeneratePlan(recover bool) (*models.Plan, error) {
|
||||
func (m *Migrator) GeneratePlan(shouldRecover bool) (*models.Plan, error) {
|
||||
diff, err := m.engine.Diff(models.Up)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
plan, err := m.engine.GeneratePlan(diff, recover)
|
||||
plan, err := m.engine.GeneratePlan(diff, shouldRecover)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -1682,10 +1682,10 @@ func applyTeamMemberViewRestrictionsFilter(query sq.SelectBuilder, restrictions
|
||||
}
|
||||
|
||||
resultQuery := query.Join("Users ru ON (TeamMembers.UserId = ru.Id)")
|
||||
if restrictions.Teams != nil && len(restrictions.Teams) > 0 {
|
||||
if len(restrictions.Teams) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("TeamMembers rtm ON ( rtm.UserId = ru.Id AND rtm.DeleteAt = 0 AND rtm.TeamId IN (%s))", sq.Placeholders(len(teams))), teams...)
|
||||
}
|
||||
if restrictions.Channels != nil && len(restrictions.Channels) > 0 {
|
||||
if len(restrictions.Channels) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("ChannelMembers rcm ON ( rcm.UserId = ru.Id AND rcm.ChannelId IN (%s))", sq.Placeholders(len(channels))), channels...)
|
||||
}
|
||||
|
||||
@@ -1712,10 +1712,10 @@ func applyTeamMemberViewRestrictionsFilterForStats(query sq.SelectBuilder, restr
|
||||
}
|
||||
|
||||
resultQuery := query
|
||||
if restrictions.Teams != nil && len(restrictions.Teams) > 0 {
|
||||
if len(restrictions.Teams) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("TeamMembers rtm ON ( rtm.UserId = Users.Id AND rtm.DeleteAt = 0 AND rtm.TeamId IN (%s))", sq.Placeholders(len(teams))), teams...)
|
||||
}
|
||||
if restrictions.Channels != nil && len(restrictions.Channels) > 0 {
|
||||
if len(restrictions.Channels) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("ChannelMembers rcm ON ( rcm.UserId = Users.Id AND rcm.ChannelId IN (%s))", sq.Placeholders(len(channels))), channels...)
|
||||
}
|
||||
|
||||
|
||||
@@ -2037,10 +2037,10 @@ func applyViewRestrictionsFilter(query sq.SelectBuilder, restrictions *model.Vie
|
||||
channels[i] = v
|
||||
}
|
||||
resultQuery := query
|
||||
if restrictions.Teams != nil && len(restrictions.Teams) > 0 {
|
||||
if len(restrictions.Teams) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("TeamMembers rtm ON ( rtm.UserId = Users.Id AND rtm.DeleteAt = 0 AND rtm.TeamId IN (%s))", sq.Placeholders(len(teams))), teams...)
|
||||
}
|
||||
if restrictions.Channels != nil && len(restrictions.Channels) > 0 {
|
||||
if len(restrictions.Channels) > 0 {
|
||||
resultQuery = resultQuery.Join(fmt.Sprintf("ChannelMembers rcm ON ( rcm.UserId = Users.Id AND rcm.ChannelId IN (%s))", sq.Placeholders(len(channels))), channels...)
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func docsCmdF(cmd *cobra.Command, args []string) error {
|
||||
return createErr
|
||||
}
|
||||
} else if !fileInfo.IsDir() {
|
||||
return fmt.Errorf(fmt.Sprintf("File \"%s\" is not a directory", outDir))
|
||||
return fmt.Errorf("File %q is not a directory", outDir)
|
||||
}
|
||||
|
||||
err = doc.GenReSTTree(RootCmd, outDir)
|
||||
|
||||
@@ -19,7 +19,7 @@ const (
|
||||
LogConfigSrcTypeFile LogConfigSrcType = "file"
|
||||
)
|
||||
|
||||
type LogSrcListener func(old, new mlog.LoggerConfiguration)
|
||||
type LogSrcListener func(oldCfg, newCfg mlog.LoggerConfiguration)
|
||||
type LogConfigSrcType string
|
||||
|
||||
// LogConfigSrc abstracts the Advanced Logging configuration so that implementations can
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module github.com/mattermost/mattermost/server/v8
|
||||
|
||||
go 1.22.0
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.22.6
|
||||
toolchain go1.23.6
|
||||
|
||||
require (
|
||||
code.sajari.com/docconv/v2 v2.0.0-pre.4
|
||||
@@ -242,10 +242,6 @@ require (
|
||||
// github.com/bits-and-blooms/bitset and a couple of dependent repos are yet
|
||||
// to update their module paths.
|
||||
exclude (
|
||||
// goquery requires go >= 1.23. Remove this once we upgrade to 1.23
|
||||
github.com/PuerkitoBio/goquery v1.9.3
|
||||
github.com/PuerkitoBio/goquery v1.10.0
|
||||
github.com/PuerkitoBio/goquery v1.10.1
|
||||
github.com/RoaringBitmap/roaring v0.7.0
|
||||
github.com/RoaringBitmap/roaring v0.7.1
|
||||
github.com/dyatlov/go-opengraph v0.0.0-20210112100619-dae8665a5b09
|
||||
|
||||
@@ -106,18 +106,18 @@ func (b *BleveEngine) SearchPosts(channels model.ChannelList, searchParams []*mo
|
||||
filters = append(filters, onDateQ)
|
||||
} else {
|
||||
if params.AfterDate != "" || params.BeforeDate != "" {
|
||||
var min, max *float64
|
||||
var rangeMin, rangeMax *float64
|
||||
if params.AfterDate != "" {
|
||||
minf := float64(params.GetAfterDateMillis())
|
||||
min = &minf
|
||||
rangeMin = &minf
|
||||
}
|
||||
|
||||
if params.BeforeDate != "" {
|
||||
maxf := float64(params.GetBeforeDateMillis())
|
||||
max = &maxf
|
||||
rangeMax = &maxf
|
||||
}
|
||||
|
||||
dateQ := bleve.NewNumericRangeQuery(min, max)
|
||||
dateQ := bleve.NewNumericRangeQuery(rangeMin, rangeMax)
|
||||
dateQ.SetField("CreateAt")
|
||||
filters = append(filters, dateQ)
|
||||
}
|
||||
@@ -666,18 +666,18 @@ func (b *BleveEngine) SearchFiles(channels model.ChannelList, searchParams []*mo
|
||||
filters = append(filters, onDateQ)
|
||||
} else {
|
||||
if params.AfterDate != "" || params.BeforeDate != "" {
|
||||
var min, max *float64
|
||||
var rangeMin, rangeMax *float64
|
||||
if params.AfterDate != "" {
|
||||
minf := float64(params.GetAfterDateMillis())
|
||||
min = &minf
|
||||
rangeMin = &minf
|
||||
}
|
||||
|
||||
if params.BeforeDate != "" {
|
||||
maxf := float64(params.GetBeforeDateMillis())
|
||||
max = &maxf
|
||||
rangeMax = &maxf
|
||||
}
|
||||
|
||||
dateQ := bleve.NewNumericRangeQuery(min, max)
|
||||
dateQ := bleve.NewNumericRangeQuery(rangeMin, rangeMax)
|
||||
dateQ.SetField("CreateAt")
|
||||
filters = append(filters, dateQ)
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ func GetMessageFromMailbox(email, id string) (JSONMessageInbucket, error) {
|
||||
}
|
||||
|
||||
// download attachments
|
||||
if record.Attachments != nil && len(record.Attachments) > 0 {
|
||||
if len(record.Attachments) > 0 {
|
||||
for i := range record.Attachments {
|
||||
var bytes []byte
|
||||
bytes, err = downloadAttachment(record.Attachments[i].DownloadLink)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module github.com/mattermost/mattermost/server/public
|
||||
|
||||
go 1.22.0
|
||||
go 1.23.0
|
||||
|
||||
toolchain go1.22.6
|
||||
toolchain go1.23.6
|
||||
|
||||
require (
|
||||
github.com/blang/semver/v4 v4.0.0
|
||||
|
||||
@@ -774,7 +774,7 @@ func (c *Client4) DoAPIRequestReader(ctx context.Context, method, url string, da
|
||||
rq.Header.Set(HeaderAuth, c.AuthType+" "+c.AuthToken)
|
||||
}
|
||||
|
||||
if c.HTTPHeader != nil && len(c.HTTPHeader) > 0 {
|
||||
if len(c.HTTPHeader) > 0 {
|
||||
for k, v := range c.HTTPHeader {
|
||||
rq.Header.Set(k, v)
|
||||
}
|
||||
|
||||
@@ -486,7 +486,7 @@ func (u *User) PreSave() *AppError {
|
||||
u.Props = make(map[string]string)
|
||||
}
|
||||
|
||||
if u.NotifyProps == nil || len(u.NotifyProps) == 0 {
|
||||
if len(u.NotifyProps) == 0 {
|
||||
u.SetDefaultNotifications()
|
||||
}
|
||||
|
||||
@@ -536,7 +536,7 @@ func (u *User) PreUpdate() {
|
||||
u.AuthData = nil
|
||||
}
|
||||
|
||||
if u.NotifyProps == nil || len(u.NotifyProps) == 0 {
|
||||
if len(u.NotifyProps) == 0 {
|
||||
u.SetDefaultNotifications()
|
||||
} else if _, ok := u.NotifyProps[MentionKeysNotifyProp]; ok {
|
||||
// Remove any blank mention keys
|
||||
|
||||
@@ -147,8 +147,8 @@ func init() {
|
||||
seen := make(map[string]string)
|
||||
|
||||
for _, version := range versions {
|
||||
maj, min, _ := SplitVersion(version)
|
||||
verStr := fmt.Sprintf("%v.%v.0", maj, min)
|
||||
major, minor, _ := SplitVersion(version)
|
||||
verStr := fmt.Sprintf("%v.%v.0", major, minor)
|
||||
|
||||
if seen[verStr] == "" {
|
||||
versionsWithoutHotFixes = append(versionsWithoutHotFixes, verStr)
|
||||
|
||||
@@ -52,7 +52,7 @@ func (l *testLogger) logf(prefix, format string, args ...interface{}) {
|
||||
measure(l.logContext)
|
||||
out += fmt.Sprintf(" -- %+v", l.logContext)
|
||||
}
|
||||
l.TB.Logf(out)
|
||||
l.TB.Log(out)
|
||||
}
|
||||
|
||||
func (l *testLogger) Debugf(format string, args ...interface{}) { l.logf("DEBUG", format, args...) }
|
||||
|
||||
Ссылка в новой задаче
Block a user