From 9148c4fe633f0405ef51cf9530507ee025f62945 Mon Sep 17 00:00:00 2001 From: Jinseong Ha <50877637+codejsha@users.noreply.github.com> Date: Sat, 7 Dec 2024 10:41:45 +0900 Subject: [PATCH 1/3] refactor: refactor to exported --- go-algorithm/pkg/sort/bubble_sort.go | 2 +- go-algorithm/pkg/sort/bubble_sort_test.go | 4 ++-- go-algorithm/pkg/sort/bucket_sort.go | 4 ++-- go-algorithm/pkg/sort/bucket_sort_test.go | 4 ++-- go-algorithm/pkg/sort/counting_sort.go | 2 +- go-algorithm/pkg/sort/counting_sort_test.go | 4 ++-- go-algorithm/pkg/sort/heap_sort.go | 12 ++++++------ go-algorithm/pkg/sort/heap_sort_test.go | 4 ++-- go-algorithm/pkg/sort/insertion_sort.go | 2 +- go-algorithm/pkg/sort/insertion_sort_test.go | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/go-algorithm/pkg/sort/bubble_sort.go b/go-algorithm/pkg/sort/bubble_sort.go index 4fad54c..bff69e9 100644 --- a/go-algorithm/pkg/sort/bubble_sort.go +++ b/go-algorithm/pkg/sort/bubble_sort.go @@ -4,7 +4,7 @@ import ( "golang.org/x/exp/constraints" ) -func bubbleSort[T constraints.Integer](arr []T) { +func BubbleSort[T constraints.Integer](arr []T) { n := len(arr) for i := 0; i < n; i++ { for j := n - 1; j > i; j-- { diff --git a/go-algorithm/pkg/sort/bubble_sort_test.go b/go-algorithm/pkg/sort/bubble_sort_test.go index de5921f..cafa085 100644 --- a/go-algorithm/pkg/sort/bubble_sort_test.go +++ b/go-algorithm/pkg/sort/bubble_sort_test.go @@ -33,9 +33,9 @@ func Test_bubbleSort(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - bubbleSort(tt.args.arr) + BubbleSort(tt.args.arr) - assert.Equalf(t, tt.want, tt.args.arr, "bubbleSort() got = %v, want %v", tt.args.arr, tt.want) + assert.Equalf(t, tt.want, tt.args.arr, "BubbleSort() got = %v, want %v", tt.args.arr, tt.want) }) } } diff --git a/go-algorithm/pkg/sort/bucket_sort.go b/go-algorithm/pkg/sort/bucket_sort.go index 64b620b..ec191e3 100644 --- a/go-algorithm/pkg/sort/bucket_sort.go +++ b/go-algorithm/pkg/sort/bucket_sort.go @@ -6,7 +6,7 @@ import ( "golang.org/x/exp/constraints" ) -func bucketSort[T constraints.Integer](arr []T) []T { +func BucketSort[T constraints.Integer](arr []T) []T { n := len(arr) var maxVal, minVal T @@ -34,7 +34,7 @@ func bucketSort[T constraints.Integer](arr []T) []T { } for i := 0; i < n; i++ { - insertionSort(bucket[i]) + InsertionSort(bucket[i]) } sorted := make([]T, 0, n) diff --git a/go-algorithm/pkg/sort/bucket_sort_test.go b/go-algorithm/pkg/sort/bucket_sort_test.go index 97c2836..c5430f0 100644 --- a/go-algorithm/pkg/sort/bucket_sort_test.go +++ b/go-algorithm/pkg/sort/bucket_sort_test.go @@ -33,9 +33,9 @@ func Test_bucketSortInteger(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got := bucketSort(tt.args.arr) + got := BucketSort(tt.args.arr) - assert.Equalf(t, tt.want, got, "bucketSort() got = %v, want %v", got, tt.want) + assert.Equalf(t, tt.want, got, "BucketSort() got = %v, want %v", got, tt.want) }) } } diff --git a/go-algorithm/pkg/sort/counting_sort.go b/go-algorithm/pkg/sort/counting_sort.go index 5474bd5..49dba4b 100644 --- a/go-algorithm/pkg/sort/counting_sort.go +++ b/go-algorithm/pkg/sort/counting_sort.go @@ -4,7 +4,7 @@ import ( "golang.org/x/exp/constraints" ) -func countingSort[T constraints.Integer](arr []T) []T { +func CountingSort[T constraints.Integer](arr []T) []T { n := len(arr) output := make([]T, n) diff --git a/go-algorithm/pkg/sort/counting_sort_test.go b/go-algorithm/pkg/sort/counting_sort_test.go index 473cf66..ec78c87 100644 --- a/go-algorithm/pkg/sort/counting_sort_test.go +++ b/go-algorithm/pkg/sort/counting_sort_test.go @@ -33,9 +33,9 @@ func Test_countingSort(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got := countingSort(tt.args.arr) + got := CountingSort(tt.args.arr) - assert.Equalf(t, tt.want, got, "countingSort() got = %v, want %v", got, tt.want) + assert.Equalf(t, tt.want, got, "CountingSort() got = %v, want %v", got, tt.want) }) } } diff --git a/go-algorithm/pkg/sort/heap_sort.go b/go-algorithm/pkg/sort/heap_sort.go index 993cbbe..9531ffa 100644 --- a/go-algorithm/pkg/sort/heap_sort.go +++ b/go-algorithm/pkg/sort/heap_sort.go @@ -4,23 +4,23 @@ import ( "golang.org/x/exp/constraints" ) -func heapSort[T constraints.Integer](arr []T) { +func HeapSort[T constraints.Integer](arr []T) { n := len(arr) - _buildMaxHeap(arr) + buildMaxHeap(arr) for i := n - 1; i > 0; i-- { arr[0], arr[i] = arr[i], arr[0] - _maxHeapify(arr, 0, i) + maxHeapify(arr, 0, i) } } -func _buildMaxHeap[T constraints.Integer](arr []T) { +func buildMaxHeap[T constraints.Integer](arr []T) { n := len(arr) for i := n/2 - 1; i >= 0; i-- { - _maxHeapify(arr, i, n) + maxHeapify(arr, i, n) } } -func _maxHeapify[T constraints.Integer](arr []T, i, n int) { +func maxHeapify[T constraints.Integer](arr []T, i, n int) { largest := i for { left := 2*i + 1 diff --git a/go-algorithm/pkg/sort/heap_sort_test.go b/go-algorithm/pkg/sort/heap_sort_test.go index 91d2ea0..36a61b6 100644 --- a/go-algorithm/pkg/sort/heap_sort_test.go +++ b/go-algorithm/pkg/sort/heap_sort_test.go @@ -32,9 +32,9 @@ func Test_heapSort(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - heapSort(tt.args.arr) + HeapSort(tt.args.arr) - assert.Equalf(t, tt.want, tt.args.arr, "heapSort() got = %v, want %v", tt.args.arr, tt.want) + assert.Equalf(t, tt.want, tt.args.arr, "HeapSort() got = %v, want %v", tt.args.arr, tt.want) }) } } diff --git a/go-algorithm/pkg/sort/insertion_sort.go b/go-algorithm/pkg/sort/insertion_sort.go index 180f1e9..a98411a 100644 --- a/go-algorithm/pkg/sort/insertion_sort.go +++ b/go-algorithm/pkg/sort/insertion_sort.go @@ -4,7 +4,7 @@ import ( "golang.org/x/exp/constraints" ) -func insertionSort[T constraints.Integer](arr []T) { +func InsertionSort[T constraints.Integer](arr []T) { for i := 0; i < len(arr); i++ { key := arr[i] j := i - 1 diff --git a/go-algorithm/pkg/sort/insertion_sort_test.go b/go-algorithm/pkg/sort/insertion_sort_test.go index bacb53b..bed83a0 100644 --- a/go-algorithm/pkg/sort/insertion_sort_test.go +++ b/go-algorithm/pkg/sort/insertion_sort_test.go @@ -33,9 +33,9 @@ func Test_insertionSort(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - insertionSort(tt.args.arr) + InsertionSort(tt.args.arr) - assert.Equalf(t, tt.want, tt.args.arr, "insertionSort() got = %v, want %v", tt.args.arr, tt.want) + assert.Equalf(t, tt.want, tt.args.arr, "InsertionSort() got = %v, want %v", tt.args.arr, tt.want) }) } } From 5d0c237c44ee685ecc50eca59213c3cdeb29c180 Mon Sep 17 00:00:00 2001 From: Jinseong Ha <50877637+codejsha@users.noreply.github.com> Date: Sat, 7 Dec 2024 10:49:26 +0900 Subject: [PATCH 2/3] chore: change format --- .github/workflows/cmake.yml | 3 +-- .github/workflows/go.yml | 8 +++----- .github/workflows/gradle.yml | 8 +++----- .github/workflows/link-check.yml | 6 ++---- .github/workflows/poetry.yml | 6 ++---- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 00db564..b7aa197 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -4,8 +4,7 @@ name: C++ CMake Test on: # every day-of-month 1st at 00:00 UTC schedule: - # prettier-ignore - - cron: '0 0 1 * *' + - cron: "0 0 1 * *" workflow_dispatch: env: diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index d6b22b2..a131b5c 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -4,8 +4,7 @@ name: Go Test on: # every day-of-month 1st at 00:00 UTC schedule: - # prettier-ignore - - cron: '0 0 1 * *' + - cron: "0 0 1 * *" workflow_dispatch: jobs: @@ -21,10 +20,9 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - # prettier-ignore - go-version: '1.22' + go-version: "1.22" cache: true - cache-dependency-path: '**/go.sum' + cache-dependency-path: "**/go.sum" - name: Download dependencies working-directory: ${{github.workspace}}/go-algorithm diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 1a6a657..24d046c 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -4,8 +4,7 @@ name: Java Gradle Test on: # every day-of-month 1st at 00:00 UTC schedule: - # prettier-ignore - - cron: '0 0 1 * *' + - cron: "0 0 1 * *" workflow_dispatch: jobs: @@ -21,9 +20,8 @@ jobs: - name: Setup JDK uses: actions/setup-java@v4 with: - # prettier-ignore - distribution: 'temurin' - java-version: '21' + distribution: "temurin" + java-version: "21" - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 diff --git a/.github/workflows/link-check.yml b/.github/workflows/link-check.yml index 653e1d8..70b97d7 100644 --- a/.github/workflows/link-check.yml +++ b/.github/workflows/link-check.yml @@ -3,8 +3,7 @@ name: Markdown Link Check on: # every sunday at 23:00 UTC schedule: - # prettier-ignore - - cron: '0 23 * * 0' + - cron: "0 23 * * 0" workflow_call: workflow_dispatch: @@ -16,5 +15,4 @@ jobs: - uses: umbrelladocs/action-linkspector@v1 with: fail_on_error: true - # prettier-ignore - config_file: '.config/linkspector.yml' + config_file: ".config/linkspector.yml" diff --git a/.github/workflows/poetry.yml b/.github/workflows/poetry.yml index d514678..a0eb4ee 100644 --- a/.github/workflows/poetry.yml +++ b/.github/workflows/poetry.yml @@ -4,8 +4,7 @@ name: Python Poetry Test on: # every day-of-month 1st at 00:00 UTC schedule: - # prettier-ignore - - cron: '0 0 1 * *' + - cron: "0 0 1 * *" workflow_dispatch: jobs: @@ -21,8 +20,7 @@ jobs: - name: Setup Python uses: actions/setup-python@v5 with: - # prettier-ignore - python-version: '3.12' + python-version: "3.12" - name: Install dependencies working-directory: ${{github.workspace}}/python-algorithm From 38ad9fec53e8ccc9187f30eda0268a865016cac0 Mon Sep 17 00:00:00 2001 From: Jinseong Ha <50877637+codejsha@users.noreply.github.com> Date: Sat, 7 Dec 2024 10:52:01 +0900 Subject: [PATCH 3/3] chore: upgrade golang version --- .github/workflows/go.yml | 2 +- README.md | 2 +- README_ko-KR.md | 2 +- go-algorithm/go.mod | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index a131b5c..6b28897 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -20,7 +20,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" cache: true cache-dependency-path: "**/go.sum" diff --git a/README.md b/README.md index 833fdd9..26c731c 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Each project is configured in specific environments, as described below: | -------- | ------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | | C++ | C++20 | [CMake](https://cmake.org/) | [GNU Scientific Library (GSL)](https://www.gnu.org/software/gsl/), [Google Test](https://google.github.io/googletest/), [Google Benchmark](https://github.com/google/benchmark), [fmt](https://github.com/fmtlib/fmt) | [vcpkg](https://github.com/microsoft/vcpkg) | | Python | 3.12 | [Poetry](https://python-poetry.org/) | [NumPy](https://numpy.org/), [SciPy](https://www.scipy.org/), [NetworkX](https://networkx.org/), [pytest](https://docs.pytest.org/), [pytest-benchmark](https://pytest-benchmark.readthedocs.io/en/latest/) | | -| Go | 1.22 | [Go](https://pkg.go.dev/cmd/go) | [Gonum](https://github.com/gonum/gonum), [Testify](https://github.com/stretchr/testify) | | +| Go | 1.23 | [Go](https://pkg.go.dev/cmd/go) | [Gonum](https://github.com/gonum/gonum), [Testify](https://github.com/stretchr/testify) | | | Java | 21 | [Gradle](https://gradle.org/) | [Google Guava](https://github.com/google/guava), [JUnit](https://junit.org/), [Java Microbenchmark Harness (JMH)](https://github.com/openjdk/jmh) | | ## Table of Contents diff --git a/README_ko-KR.md b/README_ko-KR.md index 06673d8..625d08c 100644 --- a/README_ko-KR.md +++ b/README_ko-KR.md @@ -16,5 +16,5 @@ | -------- | ------- | ------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------- | | C++ | C++20 | [CMake](https://cmake.org/) | [GNU Scientific Library (GSL)](https://www.gnu.org/software/gsl/), [Google Test](https://google.github.io/googletest/), [Google Benchmark](https://github.com/google/benchmark), [fmt](https://github.com/fmtlib/fmt) | [vcpkg](https://github.com/microsoft/vcpkg) | | Python | 3.12 | [Poetry](https://python-poetry.org/) | [NumPy](https://numpy.org/), [SciPy](https://www.scipy.org/), [NetworkX](https://networkx.org/), [pytest](https://docs.pytest.org/), [pytest-benchmark](https://pytest-benchmark.readthedocs.io/en/latest/) | | -| Go | 1.22 | [Go](https://pkg.go.dev/cmd/go) | [Gonum](https://github.com/gonum/gonum), [Testify](https://github.com/stretchr/testify) | | +| Go | 1.23 | [Go](https://pkg.go.dev/cmd/go) | [Gonum](https://github.com/gonum/gonum), [Testify](https://github.com/stretchr/testify) | | | Java | 21 | [Gradle](https://gradle.org/) | [Google Guava](https://github.com/google/guava), [JUnit](https://junit.org/), [Java Microbenchmark Harness (JMH)](https://github.com/openjdk/jmh) | | diff --git a/go-algorithm/go.mod b/go-algorithm/go.mod index caf90ef..23237fa 100644 --- a/go-algorithm/go.mod +++ b/go-algorithm/go.mod @@ -1,6 +1,6 @@ module go-algorithm -go 1.22.4 +go 1.23 require github.com/stretchr/testify v1.9.0