added a go mod file in src dir and added the base to some dagger ci stuff

This commit is contained in:
Theis
2024-03-03 10:51:45 +01:00
parent 8b50c9fd06
commit 880bc7f5eb
6 changed files with 126 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
package main
import (
"context"
"fmt"
"os"
"dagger.io/dagger"
)
func main() {
ctx := context.Background()
// initialize Dagger client
client, err := dagger.Connect(ctx, dagger.WithLogOutput(os.Stderr))
if err != nil {
panic(err)
}
defer client.Close()
// use a node:16-slim container
// mount the source code directory on the host
// at /src in the container
source := client.Container().
From("golang:1.19").
WithDirectory("/src", client.Host().Directory(".", dagger.HostDirectoryOpts{
Exclude: []string{"ci/"},
}))
// set the working directory in the container
// install application dependencies
runner := source.WithWorkdir("/src").
WithExec([]string{"go", "mod", "tidy"})
// run application tests
out, err := runner.WithExec([]string{"go", "test"}).
Stderr(ctx)
if err != nil {
panic(err)
}
fmt.Println(out)
}