Compare commits

...

2 Commits

Author SHA1 Message Date
pedro a629eb36ea add multiply 2025-05-30 01:18:52 +02:00
pedro 1761325e9c remove check version
ci/woodpecker/push/woodpecker Pipeline was successful
2025-05-30 01:16:25 +02:00
2 changed files with 9 additions and 14 deletions
-14
View File
@@ -11,20 +11,6 @@ steps:
GOARCH: amd64
commands:
- 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:
image: golang:1.24
environment:
+9
View File
@@ -32,6 +32,11 @@ func main() {
b, _ := strconv.Atoi(r.URL.Query().Get("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)
}
@@ -43,3 +48,7 @@ func sum(a, b int) int {
func sub(a, b int) int {
return a - b
}
func multiply(a, b int) int {
return a * b
}