Revert "Bump Go version to 1.23.6 (#30242)" (#30359)

This reverts commit acbbd4c58d.
Этот коммит содержится в:
Agniva De Sarker
2025-02-27 14:58:51 +05:30
коммит произвёл GitHub
родитель 690cbc9fa3
Коммит ac10bb12a5
23 изменённых файлов: 49 добавлений и 45 удалений

2
.github/workflows/codeql-analysis.yml поставляемый
Просмотреть файл

@@ -42,7 +42,7 @@ jobs:
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: server/go.mod
go-version: '1.22'
if: ${{ matrix.language == 'go' }}

Просмотреть файл

@@ -1 +1 @@
1.23.6
1.22.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.64.5
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.1
@echo Running golangci-lint
$(GOBIN)/golangci-lint run ./...

Просмотреть файл

@@ -1,4 +1,4 @@
FROM golang:1.23.6-bullseye@sha256:80eb3147ef40b58d527d9c2e634b1a79a750aee09de6f973844db38b33f0550b
FROM golang:1.22.6-bullseye@sha256:0838740c99e64dde1916553b004bdb1bc321823be83bde3d2a1563882eaab7e6
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, maxAttempts int) *model.AppError {
if user.FailedAttempts >= maxAttempts {
func checkUserLoginAttempts(user *model.User, max int) *model.AppError {
if user.FailedAttempts >= max {
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(maxInt int) (int, error) {
val, err := rand.Int(rand.Reader, big.NewInt(int64(maxInt)))
func randInt(max int) (int, error) {
val, err := rand.Int(rand.Reader, big.NewInt(int64(max)))
if err != nil {
return 0, err
}

Просмотреть файл

@@ -859,7 +859,7 @@ func (a *App) buildFullPushNotificationMessage(c request.CTX, contentsConfig str
}
}
hasFiles := len(post.FileIds) > 0
hasFiles := post.FileIds != nil && 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(oldCfg, newCfg *model.Config) {
ch.pluginConfigListenerID = ch.AddConfigListener(func(old, new *model.Config) {
// If plugin status remains unchanged, only then run this.
// Because (*App).InitPlugins is already run as a config change hook.
if *oldCfg.PluginSettings.Enable == *newCfg.PluginSettings.Enable {
if *old.PluginSettings.Enable == *new.PluginSettings.Enable {
ch.syncPluginsActiveState()
}

Просмотреть файл

@@ -232,19 +232,19 @@ func (a *App) BuildSamlMetadataObject(idpMetadata []byte) (*model.SamlMetadataRe
data := &model.SamlMetadataResponse{}
data.IdpDescriptorURL = entityDescriptor.EntityID
if len(entityDescriptor.IDPSSODescriptors) == 0 {
if entityDescriptor.IDPSSODescriptors == nil || 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 len(idpSSODescriptor.SingleSignOnServices) == 0 {
if idpSSODescriptor.SingleSignOnServices == nil || 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 len(idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors) == 0 {
if idpSSODescriptor.SSODescriptor.RoleDescriptor.KeyDescriptors == nil || 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(oldCfg, newCfg *model.Config) {
s.platform.AddConfigListener(func(old, new *model.Config) {
appInstance := New(ServerConnector(s.Channels()))
if *oldCfg.GuestAccountsSettings.Enable && !*newCfg.GuestAccountsSettings.Enable {
if *old.GuestAccountsSettings.Enable && !*new.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(shouldRecover bool) (*models.Plan, error) {
func (m *Migrator) GeneratePlan(recover bool) (*models.Plan, error) {
diff, err := m.engine.Diff(models.Up)
if err != nil {
return nil, err
}
plan, err := m.engine.GeneratePlan(diff, shouldRecover)
plan, err := m.engine.GeneratePlan(diff, recover)
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 len(restrictions.Teams) > 0 {
if restrictions.Teams != nil && 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 len(restrictions.Channels) > 0 {
if restrictions.Channels != nil && 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 len(restrictions.Teams) > 0 {
if restrictions.Teams != nil && 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 len(restrictions.Channels) > 0 {
if restrictions.Channels != nil && 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 len(restrictions.Teams) > 0 {
if restrictions.Teams != nil && 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 len(restrictions.Channels) > 0 {
if restrictions.Channels != nil && 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("File %q is not a directory", outDir)
return fmt.Errorf(fmt.Sprintf("File \"%s\" is not a directory", outDir))
}
err = doc.GenReSTTree(RootCmd, outDir)

Просмотреть файл

@@ -19,7 +19,7 @@ const (
LogConfigSrcTypeFile LogConfigSrcType = "file"
)
type LogSrcListener func(oldCfg, newCfg mlog.LoggerConfiguration)
type LogSrcListener func(old, new 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.23.0
go 1.22.0
toolchain go1.23.6
toolchain go1.22.6
require (
code.sajari.com/docconv/v2 v2.0.0-pre.4
@@ -242,6 +242,10 @@ 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 rangeMin, rangeMax *float64
var min, max *float64
if params.AfterDate != "" {
minf := float64(params.GetAfterDateMillis())
rangeMin = &minf
min = &minf
}
if params.BeforeDate != "" {
maxf := float64(params.GetBeforeDateMillis())
rangeMax = &maxf
max = &maxf
}
dateQ := bleve.NewNumericRangeQuery(rangeMin, rangeMax)
dateQ := bleve.NewNumericRangeQuery(min, max)
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 rangeMin, rangeMax *float64
var min, max *float64
if params.AfterDate != "" {
minf := float64(params.GetAfterDateMillis())
rangeMin = &minf
min = &minf
}
if params.BeforeDate != "" {
maxf := float64(params.GetBeforeDateMillis())
rangeMax = &maxf
max = &maxf
}
dateQ := bleve.NewNumericRangeQuery(rangeMin, rangeMax)
dateQ := bleve.NewNumericRangeQuery(min, max)
dateQ.SetField("CreateAt")
filters = append(filters, dateQ)
}

Просмотреть файл

@@ -103,7 +103,7 @@ func GetMessageFromMailbox(email, id string) (JSONMessageInbucket, error) {
}
// download attachments
if len(record.Attachments) > 0 {
if record.Attachments != nil && 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.23.0
go 1.22.0
toolchain go1.23.6
toolchain go1.22.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 len(c.HTTPHeader) > 0 {
if c.HTTPHeader != nil && 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 len(u.NotifyProps) == 0 {
if u.NotifyProps == nil || len(u.NotifyProps) == 0 {
u.SetDefaultNotifications()
}
@@ -536,7 +536,7 @@ func (u *User) PreUpdate() {
u.AuthData = nil
}
if len(u.NotifyProps) == 0 {
if u.NotifyProps == nil || 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 {
major, minor, _ := SplitVersion(version)
verStr := fmt.Sprintf("%v.%v.0", major, minor)
maj, min, _ := SplitVersion(version)
verStr := fmt.Sprintf("%v.%v.0", maj, min)
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.Log(out)
l.TB.Logf(out)
}
func (l *testLogger) Debugf(format string, args ...interface{}) { l.logf("DEBUG", format, args...) }