Skip to content

Commit

Permalink
feat: Upgrade Go to 1.22
Browse files Browse the repository at this point in the history
  • Loading branch information
bcessa committed Jun 17, 2024
1 parent 9930ae0 commit 966c767
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 74 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ jobs:
steps:
# Checkout code
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Go
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

# List direct dependencies
- name: List dependencies
Expand All @@ -39,27 +39,27 @@ jobs:
needs: scan
strategy:
matrix:
go-version: [1.19.x, 1.20.x]
go-version: [1.21.x, 1.22.x]
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
timeout-minutes: 15
steps:
# Checkout code
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

# Go
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}

# Style consistency and static analysis using 'golangci-lint'
# https://github.com/marketplace/actions/run-golangci-lint
- name: Static analysis
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.51.2
version: v1.54

# Run unit tests
- name: Test
Expand Down
18 changes: 9 additions & 9 deletions .github/workflows/maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ jobs:
name: "close stale issues and pull requests"
runs-on: ubuntu-latest
steps:
- uses: actions/stale@v8
- uses: actions/stale@v9
with:
# On the 'debug' mode the action will not perform any operation.
# Add the secret ACTIONS_STEP_DEBUG with a value of 'true' in the repository.
debug-only: false
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 45
days-before-close: 5
stale-issue-label: 'stale'
stale-pr-label: 'stale'
exempt-issue-labels: 'help wanted,awaiting approval,work in progress'
exempt-pr-labels: 'help wanted,awaiting approval,work in progress'
stale-issue-message: 'This issue has been marked as **stale** because it has not registered any activity during the last 45 days. If the **stale** label is not removed or no activity is registered, this will be automatically closed in 5 days.'
close-issue-message: 'This issue has been closed automatically after not registering any activity for 50 consecutive days.'
stale-pr-message: 'This pull request has been marked as **stale** because it has not registered any activity during the last 45 days. If the **stale** label is not removed or no activity is registered, this will be automatically closed in 5 days.'
close-pr-message: 'This pull request has been closed automatically after not registering any activity for 50 consecutive days.'
stale-issue-label: "stale"
stale-pr-label: "stale"
exempt-issue-labels: "help wanted,awaiting approval,work in progress"
exempt-pr-labels: "help wanted,awaiting approval,work in progress"
stale-issue-message: "This issue has been marked as **stale** because it has not registered any activity during the last 45 days. If the **stale** label is not removed or no activity is registered, this will be automatically closed in 5 days."
close-issue-message: "This issue has been closed automatically after not registering any activity for 50 consecutive days."
stale-pr-message: "This pull request has been marked as **stale** because it has not registered any activity during the last 45 days. If the **stale** label is not removed or no activity is registered, this will be automatically closed in 5 days."
close-pr-message: "This pull request has been closed automatically after not registering any activity for 50 consecutive days."
10 changes: 5 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ jobs:
steps:
# Checkout code
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
# This is required for the changelog to be properly generated
with:
fetch-depth: 0

# Go
- name: Set up Go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: 1.20.x
go-version: 1.22.x

# Use goreleaser to create the new release
# https://github.com/goreleaser/goreleaser-action
- name: Create release
uses: goreleaser/goreleaser-action@v4
uses: goreleaser/goreleaser-action@v6
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --rm-dist --skip-validate
args: release --clean --skip=validate
env:
# https://docs.github.com/en/free-pro-team@latest/actions/reference/authentication-in-a-workflow
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
Expand Down
51 changes: 26 additions & 25 deletions .golangci.yml → .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
run:
deadline: 5m
timeout: 10m
issues-exit-code: 1
tests: true
build-tags: []
skip-dirs-use-default: true
skip-files:
- ".*\\.pb\\.go$"
- ".*\\.pb\\.gw\\.go$"
- ".*\\.validator\\.pb\\.go$"
modules-download-mode: readonly
output:
format: colored-line-number
print-issued-lines: true
print-linter-name: true
linters:
Expand All @@ -25,7 +19,6 @@ linters:
- typecheck
- gocyclo
- goconst
- depguard
- misspell
- lll
- nakedret
Expand All @@ -45,39 +38,50 @@ linters:
- predeclared
- exportloopref
- whitespace
- nestif
- funlen
# Deprecated linters
#- wrapcheck
#- nestif
#- funlen
#- ifshort
#- varcheck
# - wrapcheck
# - ifshort
# - varcheck
# - structcheck
# - deadcode
disable:
- deadcode
- unused
- dupl
# https://github.com/golangci/golangci-lint/issues/2649
- structcheck
- depguard
- wastedassign
issues:
exclude-use-default: false
exclude-dirs:
# using some deprecated low level "elliptic" functions
- crypto/vrf/*
exclude-rules:
- path: _test\.go
- path: (.+)_test.go
linters:
- gocyclo
- errcheck
- dupl
- gosec
- lll
- nakedret
- revive
- funlen
- nestif
- noctx
# https://golangci-lint.run/usage/linters/#linters-configuration
linters-settings:
errcheck:
check-type-assertions: true
check-blank: false
check-type-assertions: true
disable-default-exclusions: false
# https://github.com/kisielk/errcheck#excluding-functions
exclude-functions:
- (io.Closer).Close
- (net/http.ResponseWriter).Write
- (strings.Builder).WriteByte
- (strings.Builder).WriteString
govet:
check-shadowing: false
enable:
- atomic
- atomicalign
Expand All @@ -95,26 +99,23 @@ linters-settings:
- unreachable
- unusedresult
- tests
#- fieldalignment
# - shadow
# - fieldalignment
gofmt:
simplify: true
gocyclo:
min-complexity: 18
goconst:
min-len: 3
min-occurrences: 5
depguard:
list-type: blacklist
include-go-root: false
packages: []
misspell:
locale: US
ignore-words: []
lll:
line-length: 120
tab-width: 2
nakedret:
max-func-lines: 30
max-func-lines: 40
prealloc:
simple: true
range-loops: true
Expand Down
22 changes: 9 additions & 13 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
version: 2
# main project identifier
project_name: govanity
# produced artifacts are stored in this folder
Expand All @@ -16,16 +17,15 @@ builds:
# main binary name
binary: govanity
# CLI flags for the 'go build' command
flags:
-v
flags: -v
ldflags:
- -s -w
- -X main.coreVersion={{.Version}}
- -X main.buildCode={{.Commit}}
- -X main.buildTimestamp={{.CommitDate}}
# set the modified timestamp on the output binary to ensure a
# reproducible build
mod_timestamp: '{{ .CommitTimestamp }}'
mod_timestamp: "{{ .CommitTimestamp }}"
# disable CGO since it's not supported
env:
- CGO_ENABLED=0
Expand Down Expand Up @@ -56,7 +56,6 @@ checksum:
# https://goreleaser.com/customization/source/
source:
enabled: true
rlcp: true
# produce test releases
# https://goreleaser.com/customization/snapshots/
snapshot:
Expand All @@ -65,7 +64,7 @@ snapshot:
# https://goreleaser.com/customization/release/#customize-the-changelog
changelog:
# Sorts the changelog by the commit messages (asc, desc or '')
sort: ''
sort: ""
# Remove certain commit messages from the changelog
filters:
# Standard commit messages can help to produce better changelogs
Expand All @@ -78,8 +77,7 @@ changelog:
# build and publish docker images
# https://goreleaser.com/customization/docker/
dockers:
-
# Build IDs to gather the binaries from
- # Build IDs to gather the binaries from
ids:
- govanity
# GOOS of the built binary that should be used
Expand Down Expand Up @@ -107,21 +105,20 @@ dockers:
# Produce homebrew formulas for the project artifacts
# https://goreleaser.com/customization/homebrew/
brews:
-
# Formula name
- # Formula name
name: govanity
# Push the formula to the tap repository
skip_upload: "false"
# TAP repository
tap:
repository:
owner: bryk-io
name: homebrew-tap
# Use 'github-actions' as commit author
# https://github.community/t/github-actions-bot-email-address/17204
commit_author:
name: github-actions
email: 41898282+github-actions[bot]@users.noreply.github.com
homepage: 'https://github.com/bryk-io/go-vanity'
homepage: "https://github.com/bryk-io/go-vanity"
description: |
Basic 'Remote Import Path' server for Golang packages.
install: |
Expand All @@ -131,8 +128,7 @@ brews:
# linux packages
# https://goreleaser.com/customization/nfpm/
nfpms:
-
file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
- file_name_template: "{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
builds:
- govanity
vendor: Bryk Labs
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/bryk-io/go-vanity
go 1.16

require (
github.com/kr/pretty v0.3.0 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1
)
13 changes: 5 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,27 +123,27 @@ func getServerMux(h *handler) *http.ServeMux {
mux := http.NewServeMux()

// Ping
mux.HandleFunc("/api/ping", func(res http.ResponseWriter, req *http.Request) {
mux.HandleFunc("/api/ping", func(res http.ResponseWriter, _ *http.Request) {
setHeaders(res, "text/plain; charset=utf-8", h.cache(), http.StatusOK)
_, _ = res.Write([]byte("pong"))
})

// Version
mux.HandleFunc("/api/version", func(res http.ResponseWriter, req *http.Request) {
mux.HandleFunc("/api/version", func(res http.ResponseWriter, _ *http.Request) {
js, _ := json.MarshalIndent(versionInfo(), "", " ")
setHeaders(res, "application/json", h.cache(), http.StatusOK)
_, _ = res.Write(js)
})

// Configuration
mux.HandleFunc("/api/conf", func(res http.ResponseWriter, req *http.Request) {
mux.HandleFunc("/api/conf", func(res http.ResponseWriter, _ *http.Request) {
js, _ := json.MarshalIndent(h.conf, "", " ")
setHeaders(res, "application/json", h.cache(), http.StatusOK)
_, _ = res.Write(js)
})

// Main index
mux.HandleFunc("/index.html", func(res http.ResponseWriter, req *http.Request) {
mux.HandleFunc("/index.html", func(res http.ResponseWriter, _ *http.Request) {
index, err := h.getIndex()
if err != nil {
setHeaders(res, "text/plain; charset=utf-8", h.cache(), http.StatusInternalServerError)
Expand Down

0 comments on commit 966c767

Please sign in to comment.