golang
Package main provides a set of functions to run Go language tests within a containerized environment.
Installation
dagger install github.com/dictybase-docker/dagger-of-dcr/golang@a9d74052bd6207538cdf048bf7074d8b377ae51b
Types
Golang 🔗
arangoPassword() 🔗
Return Type
String !
Example
func (m *myModule) example(ctx context.Context) string {
return dag.
Golang().
ArangoPassword(ctx)
}
arangoVersion() 🔗
Return Type
String !
Example
func (m *myModule) example(ctx context.Context) string {
return dag.
Golang().
ArangoVersion(ctx)
}
arangoPort() 🔗
Return Type
Integer !
Example
func (m *myModule) example(ctx context.Context) int {
return dag.
Golang().
ArangoPort(ctx)
}
redisPassword() 🔗
Return Type
String !
Example
func (m *myModule) example(ctx context.Context) string {
return dag.
Golang().
RedisPassword(ctx)
}
redisVersion() 🔗
Return Type
String !
Example
func (m *myModule) example(ctx context.Context) string {
return dag.
Golang().
RedisVersion(ctx)
}
redisPort() 🔗
Return Type
Integer !
Example
func (m *myModule) example(ctx context.Context) int {
return dag.
Golang().
RedisPort(ctx)
}
golangVersion() 🔗
Return Type
String !
Example
func (m *myModule) example(ctx context.Context) string {
return dag.
Golang().
GolangVersion(ctx)
}
gotestSumFormatter() 🔗
Return Type
String !
Example
func (m *myModule) example(ctx context.Context) string {
return dag.
Golang().
GotestSumFormatter(ctx)
}
withRedisVersion() 🔗
WithRedisVersion sets the version of Redis to use.
Return Type
Golang !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "7.0.12" | The version of Redis to use |
Example
func (m *myModule) example() *Golang {
return dag.
Golang().
WithRedisVersion()
}
withRedisPort() 🔗
WithRedisPort sets the port to expose Redis on.
Return Type
Golang !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
port | Integer | 6379 | The port to expose Redis on |
Example
func (m *myModule) example() *Golang {
return dag.
Golang().
WithRedisPort()
}
testsWithRedis() 🔗
TestsWithRedis runs Go tests in a container with Redis.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | The source directory to test, Required. |
args | [String ! ] | - | An optional slice of strings representing additional arguments to the go test command |
Example
func (m *myModule) example(ctx context.Context, src *Directory) string {
return dag.
Golang().
TestsWithRedis(ctx, src)
}
testsWithRedisFromGithub() 🔗
TestsWithRedisFromGithub fetches a GitHub repository and runs Go tests with Redis.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
repository | String ! | - | The GitHub repository name (e.g., "username/repo") |
gitRef | String ! | - | The git reference (branch, tag, or commit) to clone and test |
args | [String ! ] | - | An optional slice of strings representing additional arguments to the go test command |
Example
func (m *myModule) example(ctx context.Context, repository string, gitRef string) string {
return dag.
Golang().
TestsWithRedisFromGithub(ctx, repository, gitRef)
}
testsWithArangoDb() 🔗
TestsWithArangoDB runs Go tests in a container with an ArangoDB.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | The source directory to test, Required. |
args | [String ! ] | - | An optional slice of strings representing additional arguments to the go test command |
Example
func (m *myModule) example(ctx context.Context, src *Directory) string {
return dag.
Golang().
TestsWithArangoDb(ctx, src)
}
testsWithArangoDbfromGithub() 🔗
TestsWithArangoDBFromGithub fetches a GitHub repository and runs Go tests with ArangoDB.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
repository | String ! | - | The GitHub repository name (e.g., "username/repo") |
gitRef | String ! | - | The git reference (branch, tag, or commit) to clone and test |
args | [String ! ] | - | An optional slice of strings representing additional arguments to the go test command |
Example
func (m *myModule) example(ctx context.Context, repository string, gitRef string) string {
return dag.
Golang().
TestsWithArangoDbfromGithub(ctx, repository, gitRef)
}
withArangoPort() 🔗
WithArangoPort sets the port to expose ArangoDB on.
Return Type
Golang !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
port | Integer | 8529 | The port to expose ArangoDB on |
Example
func (m *myModule) example() *Golang {
return dag.
Golang().
WithArangoPort()
}
withArangoVersion() 🔗
WithArangoVersion sets the version of ArangoDB to use.
Return Type
Golang !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "3.10.9" | The version of ArangoDB to use |
Example
func (m *myModule) example() *Golang {
return dag.
Golang().
WithArangoVersion()
}
withArangoPassword() 🔗
WithArangoPassword sets the root password for the ArangoDB instance.
Return Type
Golang !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
password | String | "golam" | The root password for the ArangoDB instance |
Example
func (m *myModule) example() *Golang {
return dag.
Golang().
WithArangoPassword()
}
test() 🔗
Test runs Go tests
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
src | Directory ! | - | The source directory to test, Required. |
args | [String ! ] | - | An optional slice of strings representing additional arguments to the go test command |
Example
func (m *myModule) example(ctx context.Context, src *Directory) string {
return dag.
Golang().
Test(ctx, src)
}
lint() 🔗
Lint runs golangci-lint on the Go source code in a containerized environment. It uses a specified version of golangci-lint to perform static code analysis.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "v1.55.2-alpine" | An optional string specifying the version of golangci-lint to use |
src | Directory ! | - | The source directory to test, Required. |
args | [String ! ] | - | An optional slice of strings representing additional arguments to the golangci-lint command |
Example
func (m *myModule) example(ctx context.Context, src *Directory) string {
return dag.
Golang().
Lint(ctxsrc)
}
withGolangVersion() 🔗
WithGolangVersion sets the version of Golang to use.
Return Type
Golang !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
version | String | "1.22.6" | The version of Golang to use |
Example
func (m *myModule) example() *Golang {
return dag.
Golang().
WithGolangVersion()
}
withGotestSumFormatter() 🔗
WithGotestSumFormatter sets the output formatter for gotestsum
Return Type
Golang !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
formatter | String | "pkgname" | The output formatter to use for gotestsum |
Example
func (m *myModule) example() *Golang {
return dag.
Golang().
WithGotestSumFormatter()
}
prepareTestContainer() 🔗
PrepareTestContainer creates a container with Golang and installs gotestsum and gotestdox
Return Type
Container !
Example
func (m *myModule) example() *Container {
return dag.
Golang().
PrepareTestContainer()
}
testGitHub() 🔗
TestGitHub runs Go tests on a GitHub repository
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
repository | String ! | - | The GitHub repository name (e.g., "username/repo") |
gitRef | String ! | - | The git reference (branch, tag, or commit) to clone and test |
args | [String ! ] | - | An optional slice of strings representing additional arguments to the go test command |
Example
func (m *myModule) example(ctx context.Context, repository string, gitRef string) string {
return dag.
Golang().
TestGitHub(ctx, repository, gitRef)
}