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
6 changes: 5 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ linters:
# We often don't initialize all of the struct fields. This is fine
# generally
- exhaustruct
- exhaustruct_v5

# We tried this linter but most places we do forced type asserts are
# pretty safe, e.g., an atomic.Value when everything is encapsulated
Expand Down Expand Up @@ -739,7 +740,10 @@ formatters:

gofumpt:
module-path: github.com/maxmind/geoipupdate/v8
extra-rules: true
extra:
group-params: true
clothe-returns: true
balance-calls: true

goimports:
local-prefixes:
Expand Down
2 changes: 0 additions & 2 deletions cmd/geoipupdate/version.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
//go:build go1.12

package main

import (
Expand Down
3 changes: 1 addition & 2 deletions internal/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ func IsRetryableError(err error) bool {
return false
}

var httpErr HTTPError
if errors.As(err, &httpErr) {
if httpErr, ok := errors.AsType[HTTPError](err); ok {
return isRetryableHTTPStatusCode(httpErr.StatusCode)
}

Expand Down
1 change: 1 addition & 0 deletions internal/geoipupdate/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ func setConfigFromEnv(config *Config) error {
// takes precedence over the variable named by key.
func lookupFileOrEnv(key string) (string, bool, error) {
if path := os.Getenv(key + "_FILE"); path != "" {
//nolint:gosec // The user sets this path to the file to read.
content, err := os.ReadFile(filepath.Clean(path))
if err != nil {
return "", false, fmt.Errorf("failed to read %s_FILE: %w", key, err)
Expand Down
8 changes: 2 additions & 6 deletions internal/geoipupdate/database/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ type ReadResult struct {
}

// MarshalJSON is a custom json marshaler that strips out zero time fields.
func (r *ReadResult) MarshalJSON() ([]byte, error) {
if r == nil {
return []byte("null"), nil
}

func (r ReadResult) MarshalJSON() ([]byte, error) {
type partialResult ReadResult
s := &struct {
partialResult

ModifiedAt int64 `json:"modified_at,omitempty"`
CheckedAt int64 `json:"checked_at,omitempty"`
}{
partialResult: partialResult(*r),
partialResult: partialResult(r),
ModifiedAt: 0,
CheckedAt: 0,
}
Expand Down
3 changes: 2 additions & 1 deletion internal/geoipupdate/geoip_updater_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ func TestRetryWhenWriting(t *testing.T) {
// The md5 here belongs to the tar.gz sent below.
metadata := []byte(
`{"databases":[{"edition_id":"foo-db-name",` +
`"md5":"83e01ba43c2a66e30cb3007c1a300c78","date":"2023-04-27"}]}`)
`"md5":"83e01ba43c2a66e30cb3007c1a300c78","date":"2023-04-27"}]}`,
)
_, err := w.Write(metadata)
assert.NoError(t, err)

Expand Down
44 changes: 22 additions & 22 deletions mise.lock

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

Loading