feat: initial Go project with test
This commit is contained in:
parent
3592b907b2
commit
ecb9f584d8
3 changed files with 23 additions and 0 deletions
3
go.mod
Normal file
3
go.mod
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
module test-go-project
|
||||||
|
|
||||||
|
go 1.22
|
||||||
11
main.go
Normal file
11
main.go
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
fmt.Println("Hello from Forgejo!")
|
||||||
|
}
|
||||||
|
|
||||||
|
func Add(a, b int) int {
|
||||||
|
return a + b
|
||||||
|
}
|
||||||
9
main_test.go
Normal file
9
main_test.go
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestAdd(t *testing.T) {
|
||||||
|
if got := Add(2, 3); got != 5 {
|
||||||
|
t.Errorf("Add(2, 3) = %d, want 5", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue