Compare commits
No commits in common. "c8167af6181f299aa6d31137bf0ac9ff90d3686a" and "cf4ee051bb23182c790e8870c8eb4c5a4c3b7666" have entirely different histories.
c8167af618
...
cf4ee051bb
@ -11,20 +11,6 @@ steps:
|
|||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
commands:
|
commands:
|
||||||
- go test ./...
|
- go test ./...
|
||||||
go-check-version:
|
|
||||||
image: golang:1.24
|
|
||||||
commands:
|
|
||||||
- echo "Checking project version..."
|
|
||||||
- VERSION_CURRENT=$(grep 'version =' main.go | cut -d'"' -f2)
|
|
||||||
- PREV_COMMIT=$(git rev-parse HEAD^)
|
|
||||||
- VERSION_PREV=$(git show "$PREV_COMMIT:main.go" | grep 'version =' | cut -d'"' -f2)
|
|
||||||
- |
|
|
||||||
if [ "$VERSION_CURRENT" = "$VERSION_PREV" ]; then
|
|
||||||
echo "❌ The version has not changed. You must update it to merge to main."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
echo "✅ The version has changed correctly."
|
|
||||||
fi
|
|
||||||
go-build:
|
go-build:
|
||||||
image: golang:1.24
|
image: golang:1.24
|
||||||
environment:
|
environment:
|
||||||
|
|||||||
9
main.go
9
main.go
@ -27,11 +27,6 @@ func main() {
|
|||||||
b, _ := strconv.Atoi(r.URL.Query().Get("b"))
|
b, _ := strconv.Atoi(r.URL.Query().Get("b"))
|
||||||
json.NewEncoder(w).Encode(map[string]int{"result": sum(a, b)})
|
json.NewEncoder(w).Encode(map[string]int{"result": sum(a, b)})
|
||||||
})
|
})
|
||||||
mux.HandleFunc("/sub", func(w http.ResponseWriter, r *http.Request) {
|
|
||||||
a, _ := strconv.Atoi(r.URL.Query().Get("a"))
|
|
||||||
b, _ := strconv.Atoi(r.URL.Query().Get("b"))
|
|
||||||
json.NewEncoder(w).Encode(map[string]int{"result": sub(a, b)})
|
|
||||||
})
|
|
||||||
|
|
||||||
http.ListenAndServe(":8080", mux)
|
http.ListenAndServe(":8080", mux)
|
||||||
}
|
}
|
||||||
@ -39,7 +34,3 @@ func main() {
|
|||||||
func sum(a, b int) int {
|
func sum(a, b int) int {
|
||||||
return a + b
|
return a + b
|
||||||
}
|
}
|
||||||
|
|
||||||
func sub(a, b int) int {
|
|
||||||
return a - b
|
|
||||||
}
|
|
||||||
|
|||||||
17
main_test.go
17
main_test.go
@ -20,20 +20,3 @@ func Test_sum(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_sub(t *testing.T) {
|
|
||||||
tests := []struct {
|
|
||||||
a, b int
|
|
||||||
want int
|
|
||||||
}{
|
|
||||||
{1, 2, -1},
|
|
||||||
{-1, 1, -2},
|
|
||||||
{0, 0, 0},
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
|
||||||
if got := sub(test.a, test.b); got != test.want {
|
|
||||||
t.Errorf("sub(%d, %d) = %d, want %d", test.a, test.b, got, test.want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user