Update to Go 1.20 + run better align (#2927)

* chore(go): update go version to 1.20. Closes #2185

* chore(go): run better align against project

To optimize struct field order. Closes #2870

* chore(go): update CI jobs to use Go 1.20

* fix(go): linter warnings for Go 1.20 update
This commit is contained in:
Gabe Kangas
2023-05-30 10:31:43 -07:00
committed by GitHub
parent 7e0907e16c
commit 85e7af3d5f
47 changed files with 248 additions and 695 deletions

View File

@@ -44,9 +44,9 @@ func GetWarnings(w http.ResponseWriter, r *http.Request) {
}
type logsResponse struct {
Time time.Time `json:"time"`
Message string `json:"message"`
Level string `json:"level"`
Time time.Time `json:"time"`
}
func fromEntry(e *logrus.Entry) logsResponse {

View File

@@ -99,27 +99,27 @@ func GetServerConfig(w http.ResponseWriter, r *http.Request) {
type serverConfigAdminResponse struct {
InstanceDetails webConfigResponse `json:"instanceDetails"`
Notifications notificationsConfigResponse `json:"notifications"`
YP yp `json:"yp"`
FFmpegPath string `json:"ffmpegPath"`
AdminPassword string `json:"adminPassword"`
StreamKeys []models.StreamKey `json:"streamKeys"`
StreamKeyOverridden bool `json:"streamKeyOverridden"`
WebServerPort int `json:"webServerPort"`
SocketHostOverride string `json:"socketHostOverride,omitempty"`
WebServerIP string `json:"webServerIP"`
RTMPServerPort int `json:"rtmpServerPort"`
VideoCodec string `json:"videoCodec"`
S3 models.S3 `json:"s3"`
Federation federationConfigResponse `json:"federation"`
SupportedCodecs []string `json:"supportedCodecs"`
ExternalActions []models.ExternalAction `json:"externalActions"`
ForbiddenUsernames []string `json:"forbiddenUsernames"`
SuggestedUsernames []string `json:"suggestedUsernames"`
StreamKeys []models.StreamKey `json:"streamKeys"`
VideoSettings videoSettings `json:"videoSettings"`
YP yp `json:"yp"`
RTMPServerPort int `json:"rtmpServerPort"`
WebServerPort int `json:"webServerPort"`
ChatDisabled bool `json:"chatDisabled"`
ChatJoinMessagesEnabled bool `json:"chatJoinMessagesEnabled"`
ChatEstablishedUserMode bool `json:"chatEstablishedUserMode"`
ExternalActions []models.ExternalAction `json:"externalActions"`
SupportedCodecs []string `json:"supportedCodecs"`
VideoCodec string `json:"videoCodec"`
ForbiddenUsernames []string `json:"forbiddenUsernames"`
Federation federationConfigResponse `json:"federation"`
SuggestedUsernames []string `json:"suggestedUsernames"`
SocketHostOverride string `json:"socketHostOverride,omitempty"`
Notifications notificationsConfigResponse `json:"notifications"`
StreamKeyOverridden bool `json:"streamKeyOverridden"`
HideViewerCount bool `json:"hideViewerCount"`
}
@@ -129,35 +129,35 @@ type videoSettings struct {
}
type webConfigResponse struct {
Name string `json:"name"`
Summary string `json:"summary"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
Version string `json:"version"`
WelcomeMessage string `json:"welcomeMessage"`
OfflineMessage string `json:"offlineMessage"`
Logo string `json:"logo"`
Tags []string `json:"tags"`
Version string `json:"version"`
NSFW bool `json:"nsfw"`
Name string `json:"name"`
ExtraPageContent string `json:"extraPageContent"`
StreamTitle string `json:"streamTitle"` // What's going on with the current stream
SocialHandles []models.SocialHandle `json:"socialHandles"`
CustomStyles string `json:"customStyles"`
CustomJavascript string `json:"customJavascript"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
Summary string `json:"summary"`
Tags []string `json:"tags"`
SocialHandles []models.SocialHandle `json:"socialHandles"`
NSFW bool `json:"nsfw"`
}
type yp struct {
Enabled bool `json:"enabled"`
InstanceURL string `json:"instanceUrl"` // The public URL the directory should link to
YPServiceURL string `json:"-"` // The base URL to the YP API to register with (optional)
Enabled bool `json:"enabled"`
}
type federationConfigResponse struct {
Enabled bool `json:"enabled"`
IsPrivate bool `json:"isPrivate"`
Username string `json:"username"`
GoLiveMessage string `json:"goLiveMessage"`
ShowEngagement bool `json:"showEngagement"`
BlockedDomains []string `json:"blockedDomains"`
Enabled bool `json:"enabled"`
IsPrivate bool `json:"isPrivate"`
ShowEngagement bool `json:"showEngagement"`
}
type notificationsConfigResponse struct {

View File

@@ -42,11 +42,11 @@ func Status(w http.ResponseWriter, r *http.Request) {
type adminStatusResponse struct {
Broadcaster *models.Broadcaster `json:"broadcaster"`
CurrentBroadcast *models.CurrentBroadcast `json:"currentBroadcast"`
Online bool `json:"online"`
Health *models.StreamHealthOverview `json:"health"`
StreamTitle string `json:"streamTitle"`
VersionNumber string `json:"versionNumber"`
ViewerCount int `json:"viewerCount"`
OverallPeakViewerCount int `json:"overallPeakViewerCount"`
SessionPeakViewerCount int `json:"sessionPeakViewerCount"`
StreamTitle string `json:"streamTitle"`
Health *models.StreamHealthOverview `json:"health"`
VersionNumber string `json:"versionNumber"`
Online bool `json:"online"`
}

View File

@@ -16,37 +16,37 @@ import (
)
type webConfigResponse struct {
Name string `json:"name"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
Notifications notificationsConfigResponse `json:"notifications"`
CustomStyles string `json:"customStyles"`
Summary string `json:"summary"`
OfflineMessage string `json:"offlineMessage"`
Logo string `json:"logo"`
Tags []string `json:"tags"`
Version string `json:"version"`
NSFW bool `json:"nsfw"`
SocketHostOverride string `json:"socketHostOverride,omitempty"`
ExtraPageContent string `json:"extraPageContent"`
StreamTitle string `json:"streamTitle,omitempty"` // What's going on with the current stream
SocialHandles []models.SocialHandle `json:"socialHandles"`
ChatDisabled bool `json:"chatDisabled"`
ExternalActions []models.ExternalAction `json:"externalActions"`
CustomStyles string `json:"customStyles"`
AppearanceVariables map[string]string `json:"appearanceVariables"`
MaxSocketPayloadSize int `json:"maxSocketPayloadSize"`
Name string `json:"name"`
Federation federationConfigResponse `json:"federation"`
Notifications notificationsConfigResponse `json:"notifications"`
SocialHandles []models.SocialHandle `json:"socialHandles"`
ExternalActions []models.ExternalAction `json:"externalActions"`
Tags []string `json:"tags"`
MaxSocketPayloadSize int `json:"maxSocketPayloadSize"`
ChatDisabled bool `json:"chatDisabled"`
NSFW bool `json:"nsfw"`
Authentication authenticationConfigResponse `json:"authentication"`
HideViewerCount bool `json:"hideViewerCount"`
}
type federationConfigResponse struct {
Enabled bool `json:"enabled"`
Account string `json:"account,omitempty"`
FollowerCount int `json:"followerCount,omitempty"`
Enabled bool `json:"enabled"`
}
type browserNotificationsConfigResponse struct {
Enabled bool `json:"enabled"`
PublicKey string `json:"publicKey,omitempty"`
Enabled bool `json:"enabled"`
}
type notificationsConfigResponse struct {

View File

@@ -16,11 +16,11 @@ import (
// GetUserDetails returns the details of a chat user for moderators.
func GetUserDetails(w http.ResponseWriter, r *http.Request) {
type connectedClient struct {
ConnectedAt time.Time `json:"connectedAt"`
UserAgent string `json:"userAgent"`
Geo string `json:"geo,omitempty"`
Id uint `json:"id"`
MessageCount int `json:"messageCount"`
UserAgent string `json:"userAgent"`
ConnectedAt time.Time `json:"connectedAt"`
Geo string `json:"geo,omitempty"`
}
type response struct {

View File

@@ -2,6 +2,6 @@ package controllers
// PaginatedResponse is a structure for returning a total count with results.
type PaginatedResponse struct {
Total int `json:"total"`
Results interface{} `json:"results"`
Total int `json:"total"`
}

View File

@@ -40,12 +40,12 @@ func getStatusResponse() webStatusResponse {
}
type webStatusResponse struct {
Online bool `json:"online"`
ViewerCount int `json:"viewerCount,omitempty"`
ServerTime time.Time `json:"serverTime"`
LastConnectTime *utils.NullTime `json:"lastConnectTime"`
LastDisconnectTime *utils.NullTime `json:"lastDisconnectTime"`
VersionNumber string `json:"versionNumber"`
StreamTitle string `json:"streamTitle"`
ViewerCount int `json:"viewerCount,omitempty"`
Online bool `json:"online"`
}

View File

@@ -8,15 +8,15 @@ import (
)
type variantsSort struct {
Index int
Name string
IsVideoPassthrough bool
Index int
VideoBitrate int
IsVideoPassthrough bool
}
type variantsResponse struct {
Index int `json:"index"`
Name string `json:"name"`
Index int `json:"index"`
}
// GetVideoStreamOutputVariants will return the video variants available.