Compare commits
No commits in common. "a629eb36ea0c7b2a788977a61a952df54bbf4b0a" and "012ab48110050ac4b6aa6cc419c37224817d7904" have entirely different histories.
a629eb36ea
...
012ab48110
@ -11,6 +11,22 @@ 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)
|
||||||
|
- echo "Project version: $VERSION_CURRENT"
|
||||||
|
- PREV_COMMIT=$(git rev-parse HEAD^)
|
||||||
|
- VERSION_PREV=$(git show "$PREV_COMMIT:main.go" | grep 'version =' | cut -d'"' -f2)
|
||||||
|
- echo "Previous version: $VERSION_PREV"
|
||||||
|
- |
|
||||||
|
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
@ -32,11 +32,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": sub(a, b)})
|
json.NewEncoder(w).Encode(map[string]int{"result": sub(a, b)})
|
||||||
})
|
})
|
||||||
mux.HandleFunc("/multiply", 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": multiply(a, b)})
|
|
||||||
})
|
|
||||||
|
|
||||||
http.ListenAndServe(":8080", mux)
|
http.ListenAndServe(":8080", mux)
|
||||||
}
|
}
|
||||||
@ -48,7 +43,3 @@ func sum(a, b int) int {
|
|||||||
func sub(a, b int) int {
|
func sub(a, b int) int {
|
||||||
return a - b
|
return a - b
|
||||||
}
|
}
|
||||||
|
|
||||||
func multiply(a, b int) int {
|
|
||||||
return a * b
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user