Skip to content
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/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Install Go
uses: actions/setup-go@v6
with:
go-version: '1.25'
go-version: '1.26'

- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ permissions:
jobs:
test:
runs-on: ubuntu-24.04
name: Go 1.23
name: Go 1.26
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -20,7 +20,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.23
go-version: 1.26

- name: Setup go-acc
run: go install github.com/ory/go-acc@latest
Expand Down
2 changes: 1 addition & 1 deletion api/routes/get/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func twitchLoginHandler(writer http.ResponseWriter, request *http.Request) { //n
}

// Excahnge code for access token
tokenResp, err := client.Do(req)
tokenResp, err := client.Do(req) //nolint:gosec
if err != nil {
http.Error(writer, "Failed to get access token", http.StatusInternalServerError)

Expand Down
4 changes: 2 additions & 2 deletions api/routes/post/redirects.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func createRedirect(writer http.ResponseWriter, request *http.Request) { //nolin
key, err := postgres.GetKeyByRedirect(request.Context(), input.URL)
if err == nil && key != "" {
response := fmt.Sprintf("https://%s/%s", request.Host, key)
_, err = writer.Write([]byte(response))
_, err = writer.Write([]byte(response)) //nolint:gosec
if err != nil {
logger.Error.Printf("Failed to write response: %v", err)
}
Expand All @@ -72,7 +72,7 @@ func createRedirect(writer http.ResponseWriter, request *http.Request) { //nolin
}

response := fmt.Sprintf("https://%s/%s", request.Host, key)
if _, err = writer.Write([]byte(response)); err != nil {
if _, err = writer.Write([]byte(response)); err != nil { //nolint:gosec
logger.Error.Printf("Failed to write response: %v", err)
}
}
Expand Down
6 changes: 3 additions & 3 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type Config struct {
// TwitchConfig holds the configuration for Twitch API integration.
type TwitchConfig struct {
ClientID string `json:"client_id"`
ClientSecret string `json:"client_secret"`
ClientSecret string `json:"client_secret"` //nolint:gosec
OauthURI string `json:"oauth_uri"`
}

Expand All @@ -33,7 +33,7 @@ type BoolConfig struct {
type APIConfig struct {
Host string `json:"host"`
Port string `json:"port"`
AuthKey string `json:"authkey,omitempty"`
AuthKey string `json:"authkey,omitempty"` //nolint:gosec
Enabled bool `json:"enabled"`
}

Expand All @@ -51,7 +51,7 @@ type SQLConfig struct {
Host string `json:"host"`
Port string `json:"port"`
User string `json:"user"`
Password string `json:"password"`
Password string `json:"password"` //nolint:gosec
Database string `json:"database"`
}

Expand Down
2 changes: 1 addition & 1 deletion common/db/loops.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ func backupPostgres(
fmt.Sprintf("data_%d.sql.zst", time.Now().Unix()),
)

//nolint:gosec
//nolint:gosec,noctx
cmd := exec.Command("sh", "-c", fmt.Sprintf(
"PGPASSWORD=%s pg_dump -d %s -U %s -h %s | zstd -3 --threads=%d > %s",
config.Postgres.Password,
Expand Down
6 changes: 4 additions & 2 deletions common/db/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ func InitPostgres(ctx context.Context, config common.Config) (*PostgresClient, e
return &PostgresClient{pool}, nil
}

func loadConfig(config common.Config) (*pgxpool.Config, error) {
func loadConfig(config common.Config) (*pgxpool.Config, error) { //nolint:unparam
user := config.Postgres.User
if user == "" {
user = "postgres"
}

host := config.Postgres.Host
if host == "" {
host = "localhost"
host = "localhost" //nolint:goconst
}

port := config.Postgres.Port
Expand Down Expand Up @@ -399,6 +399,8 @@ func (db *PostgresClient) getChannelByType( //nolint:cyclop
*channel.Blocks.Users = append(*channel.Blocks.Users, block)
case common.CommandBlock:
*channel.Blocks.Commands = append(*channel.Blocks.Commands, block)
case common.GlobalBlock:
continue
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion common/db/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var ErrRedisNil = redis.Nil
func InitRedis(config common.Config) (*RedisClient, error) {
host := config.Redis.Host
if host == "" {
host = "localhost"
host = "localhost" //nolint:goconst
}

port := config.Redis.Port
Expand Down
12 changes: 6 additions & 6 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type TwitchChannelMeta struct {
// TwitchUserMeta represents the metadata for a user on Twitch, including their color and roles.
type TwitchUserMeta struct {
Color string `json:"color,omitempty"`
Roles TwitchRoles `json:"roles,omitempty"`
Roles TwitchRoles `json:"roles,omitzero"`
}

// StvUserMeta represents the metadata for a user on 7TV, including their paint ID and roles.
Expand All @@ -98,7 +98,7 @@ type TwitchRoles struct {

// Channel represents a channel on a platform, including its blocks, settings, commands, and other metadata.
type Channel struct {
Blocks FilteredBlocks `json:"blocks,omitempty"`
Blocks FilteredBlocks `json:"blocks,omitzero"`
JoinedAt *time.Time `json:"joined_at,omitempty"`
Meta map[string]any `json:"meta"`
Commands *[]ChannelCommand `json:"commands,omitempty"`
Expand Down Expand Up @@ -183,8 +183,8 @@ type CommandSettings struct {
type PlatformOauth struct {
AddedAt time.Time `json:"added_at"`
PlatformID string `json:"platform_id"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
AccessToken string `json:"access_token"` //nolint:gosec
RefreshToken string `json:"refresh_token"` //nolint:gosec
Platform Platforms `json:"platform"`
Scope []string `json:"scope"`
ExpiresIn int `json:"expires_in"`
Expand Down Expand Up @@ -298,8 +298,8 @@ type TwitchValidation struct {

// GenericOAUTHResponse represents a generic OAuth response structure.
type GenericOAUTHResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
AccessToken string `json:"access_token"` //nolint:gosec
RefreshToken string `json:"refresh_token"` //nolint:gosec
TokenType string `json:"token_type"`
Scope []string `json:"scope"`
ExpiresIn int `json:"expires_in"`
Expand Down
2 changes: 1 addition & 1 deletion common/utils/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func makeRequest(
Timeout: time.Second * 10,
}

res, err := client.Do(req)
res, err := client.Do(req) //nolint:gosec
if err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ require (
github.com/prometheus/client_golang v1.21.1
github.com/redis/go-redis/v9 v9.7.3
github.com/robfig/cron/v3 v3.0.1
github.com/stretchr/testify v1.10.0
)

require (
github.com/ClickHouse/ch-go v0.65.1 // indirect
github.com/andybalholm/brotli v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/go-faster/city v1.0.1 // indirect
github.com/go-faster/errors v0.7.1 // indirect
Expand All @@ -36,6 +38,7 @@ require (
github.com/paulmach/orb v0.11.1 // indirect
github.com/pierrec/lz4/v4 v4.1.22 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.6.1 // indirect
github.com/prometheus/common v0.63.0 // indirect
github.com/prometheus/procfs v0.16.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions haste/haste.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func (h *hastebin) handleGetRaw(writer http.ResponseWriter, request *http.Reques
writer.Header().Set("Content-Type", "text/plain; charset=utf-8")
writer.Header().Set("X-Cache-Hit", "HIT")
writer.WriteHeader(http.StatusOK)
_, err = writer.Write([]byte(cache))
_, err = writer.Write([]byte(cache)) //nolint:gosec
if err != nil {
logger.Warn.Println("Failed to write document: ", err)
}
Expand All @@ -224,7 +224,7 @@ func (h *hastebin) handleGetRaw(writer http.ResponseWriter, request *http.Reques
writer.Header().Set("Content-Type", "text/plain; charset=utf-8")
writer.Header().Set("X-Cache-Hit", "MISS")
writer.WriteHeader(http.StatusOK)
_, err = writer.Write([]byte(data))
_, err = writer.Write([]byte(data)) //nolint:gosec
if err != nil {
logger.Warn.Println("Failed to write document: ", err)
}
Expand Down
12 changes: 6 additions & 6 deletions redirects/redirects_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package redirects
import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func TestRedirects__CheckProtocolFormatAfterProtocolReformat(t *testing.T) {
Expand All @@ -21,12 +23,10 @@ func TestRedirects__CheckProtocolFormatAfterProtocolReformat(t *testing.T) {
for _, tc := range tests {
t.Run(tc.input, func(t *testing.T) {
cleanedURL := redirector.cleanRedirectProtocolSoLinksActuallyWork(tc.input)
if !strings.HasPrefix(cleanedURL, "https://") {
t.Errorf("Expected cleaned URL to start with 'https://', got %q", cleanedURL)
}
if cleanedURL != tc.expected {
t.Errorf("Expected %q, got %q", tc.expected, cleanedURL)
}
assert.Truef(
t, strings.HasPrefix(cleanedURL, "https://"), "Expected cleaned URL to start with 'https://', got %q", cleanedURL,
)
assert.Equal(t, tc.expected, cleanedURL)
})
}
}
4 changes: 2 additions & 2 deletions uploader/uploader.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ func (u *uploader) handleGet(writer http.ResponseWriter, request *http.Request)
writer.Header().Set("Content-Type", contentType)
writer.Header().Set("X-Cache-Hit", "HIT")
writer.WriteHeader(http.StatusOK)
_, err = writer.Write(cache)
_, err = writer.Write(cache) //nolint:gosec
if err != nil {
logger.Warn.Printf("Failed to write document: %v", err)
}
Expand Down Expand Up @@ -262,7 +262,7 @@ func (u *uploader) handleGet(writer http.ResponseWriter, request *http.Request)
writer.Header().Set("Content-Disposition", "inline; filename=\""+*name+"\"")
}
writer.Header().Set("Content-Type", mimeType)
_, err = writer.Write(data)
_, err = writer.Write(data) //nolint:gosec
if err != nil {
logger.Error.Printf("Error writing file: %v", err)
http.Error(writer, "Failed to write file", http.StatusInternalServerError)
Expand Down
Loading