commit c1b04de8eacd3012fccd6b3d6e7dc82928736a04 Author: Antonio De Lucreziis Date: Tue Feb 14 19:31:29 2023 +0100 initial commit diff --git a/.drone.yaml b/.drone.yaml new file mode 100644 index 0000000..9d27fac --- /dev/null +++ b/.drone.yaml @@ -0,0 +1,9 @@ +kind: pipeline +name: default + +steps: +- name: test + image: golang + commands: + - go test -v ./... + - go build diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e7b251c --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ +.env +*.local* + +node_modules/ + +bin/ +.out/ +out/ +dist/ + +.vscode/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..3ee873d --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Drone Example + +Un piccolo progetto di esempio per mostrare come funziona [Drone](https://build.phc.dm.unipi.it) + diff --git a/drone-example b/drone-example new file mode 100755 index 0000000..f70dbf5 Binary files /dev/null and b/drone-example differ diff --git a/foo/foo.go b/foo/foo.go new file mode 100644 index 0000000..ecccdce --- /dev/null +++ b/foo/foo.go @@ -0,0 +1,5 @@ +package foo + +func Sum(a, b int) int { + return a + b +} diff --git a/foo/foo_test.go b/foo/foo_test.go new file mode 100644 index 0000000..338e124 --- /dev/null +++ b/foo/foo_test.go @@ -0,0 +1,12 @@ +package foo_test + +import ( + "testing" + + "git.phc.dm.unipi.it/phc/drone-example/foo" + "github.com/alecthomas/assert/v2" +) + +func TestFoo(t *testing.T) { + assert.Equal(t, 111, foo.Sum(42, 69)) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..158dc4d --- /dev/null +++ b/go.mod @@ -0,0 +1,9 @@ +module git.phc.dm.unipi.it/phc/drone-example + +go 1.19 + +require ( + github.com/alecthomas/assert/v2 v2.2.1 // indirect + github.com/alecthomas/repr v0.2.0 // indirect + github.com/hexops/gotextdiff v1.0.3 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..ec9924a --- /dev/null +++ b/go.sum @@ -0,0 +1,6 @@ +github.com/alecthomas/assert/v2 v2.2.1 h1:XivOgYcduV98QCahG8T5XTezV5bylXe+lBxLG2K2ink= +github.com/alecthomas/assert/v2 v2.2.1/go.mod h1:pXcQ2Asjp247dahGEmsZ6ru0UVwnkhktn7S0bBDLxvQ= +github.com/alecthomas/repr v0.2.0 h1:HAzS41CIzNW5syS8Mf9UwXhNH1J9aix/BvDRf1Ml2Yk= +github.com/alecthomas/repr v0.2.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= +github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM= +github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg= diff --git a/main.go b/main.go new file mode 100644 index 0000000..8fca152 --- /dev/null +++ b/main.go @@ -0,0 +1,24 @@ +package main + +import ( + "fmt" + "log" + + "git.phc.dm.unipi.it/phc/drone-example/foo" +) + +func main() { + var a, b int + + fmt.Printf("a = ") + if _, err := fmt.Scanln("%d", &a); err != nil { + log.Fatal(err) + } + fmt.Printf("b = ") + if _, err := fmt.Scanln("%d", &b); err != nil { + log.Fatal(err) + } + + result := foo.Sum(a, b) + log.Printf("a + b = %v", result) +}