diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2293db..3b7a6d7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -59,6 +59,7 @@ jobs: go test -v -race -coverprofile=coverage -covermode=atomic ./... - name: Upload coverage to Codecov + if: matrix.os == 'ubuntu-latest' uses: codecov/codecov-action@v4 with: files: ./coverage diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2c0dcca..f8d1fe9 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -26,11 +26,7 @@ jobs: # We must fetch at least the immediate parents so that if this is # a pull request then we can checkout the head. fetch-depth: 2 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "1.22.x" - cache: false + # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL uses: github/codeql-action/init@v3 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d0d65b2..ea66254 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -11,11 +11,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: "1.22.x" - cache: false - name: Run golangci-lint uses: golangci/golangci-lint-action@v6 with: # BUG: typecheck error when enable all diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..de8f15c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,41 @@ +name: goreleaser + +on: + push: + # run only against tags + tags: + - "*" + +permissions: + contents: write + # packages: write + # issues: write + +jobs: + goreleaser: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - run: git fetch --force --tags + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: ">=1.22.0" + cache: true + # More assembly might be required: Docker logins, GPG, etc. It all depends + # on your needs. + - name: Release binary + uses: goreleaser/goreleaser-action@v6 + with: + # either 'goreleaser' (default) or 'goreleaser-pro': + distribution: goreleaser + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Your GoReleaser Pro key, if you are using the 'goreleaser-pro' + # distribution: + # GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..78ba54e --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,70 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 1 + +env: + - GO111MODULE=on + +snapshot: + name_template: "{{ incpatch .Version }}-next" + +# before: +# hooks: +# # You may remove this if you don't use go modules. +# - go mod tidy +# # you may remove this if you don't need go generate +# - go generate ./... + +builds: + - main: . + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + - "386" + - arm + goarm: + - "7" + mod_timestamp: "{{ .CommitTimestamp }}" + flags: + - -trimpath + ldflags: + - -s -w + # If true, skip the build. for library projects. + skip: true + +archives: + - name_template: >- + {{ .ProjectName }}_ + {{- .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }}' + format_overrides: + - goos: windows + format: zip + +checksum: + name_template: "checksums.txt" + +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" +# modelines, feel free to remove those if you don't want/use them: +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj diff --git a/queue/priority_queue.go b/queue/priority_queue.go index 6fd71c3..4e36d47 100644 --- a/queue/priority_queue.go +++ b/queue/priority_queue.go @@ -45,15 +45,15 @@ func NewPriorityQueue[T cmp.Ordered](maxHeap bool, items ...T) *PriorityQueue[T] // NewPriorityQueue initializes and returns an Queue, default min heap. func NewPriorityQueueWith[T comparable](maxHeap bool, compare comparator.Comparable[T], items ...T) *PriorityQueue[T] { - q := &PriorityQueue[T]{ + pq := &PriorityQueue[T]{ container: &comparator.Container[T]{ Items: items, Desc: maxHeap, Compare: compare, }, } - heap.Init(q.container) - return q + heap.Init(pq.container) + return pq } // Len returns the length of this priority queue.