Compare commits

..

3 commits

Author SHA1 Message Date
Imbus
bbaf156601 Make -> just 2024-01-05 16:27:28 +01:00
Imbus
22f200c2b4 Better gitignore 2024-01-05 16:27:21 +01:00
Imbus
9cc368ff2d Sources with test 2024-01-05 16:24:45 +01:00
7 changed files with 61 additions and 12 deletions

19
.gitignore vendored Normal file
View file

@ -0,0 +1,19 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib
bin
# Test binary, built with `go test -c`
*.test
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
# Dependency directories (remove the comment below to include it)
vendor/
# Go workspace file
go.work

15
justfile Normal file
View file

@ -0,0 +1,15 @@
run:
cd src && go run .
build:
mkdir -p bin
cd src && go build -o ../bin/main .
test:
cd src && go test -v .
clean:
rm -rf bin/*
format:
go fmt src/*.go

View file

@ -1,11 +0,0 @@
run:
go run src/*.go
build:
go build -o bin/main src/main.go
clean:
rm -rf bin/*
format:
go fmt src/*.go

6
src/add.go Normal file
View file

@ -0,0 +1,6 @@
package main
// Sophisticated mathematics for sophisticated homosapiens
func add(x, y int) int {
return x + y
}

16
src/add_test.go Normal file
View file

@ -0,0 +1,16 @@
package main
import (
"testing"
)
// This file is named add_test.go by convention.
// The go test command will automatically detect this file and run it.
// All test files must be named *_test.go and all test functions must be named Test*.
// TestAdd is a test function
func TestAdd(t *testing.T) {
if add(1, 2) != 3 {
t.Error("Expected 3")
}
}

View file

@ -1,7 +1,10 @@
package main
import "fmt"
import (
"fmt"
)
// Greets the world
func greet() {
fmt.Println("Hello World!")
}

View file

@ -2,4 +2,5 @@ package main
func main() {
greet()
println(add(1, 2))
}