golangx

package
v0.0.16 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGoModule added in v0.0.14

func IsGoModule(path string) error

IsGoModule checks if the given path is a Go module.

Parameters:

  • path: The path to check.

Returns:

  • An error if the path is not a Go module.

Example:

err := IsGoModule("path/to/go/module")
if err != nil {
    // handle error
}
// Use err, e.g., fmt.Println(err) // Output: path is not a Go module

func WithGoCgoDisabled

func WithGoCgoDisabled() types.DaggerEnvVars

WithGoCgoDisabled returns a DaggerEnvVars struct that sets the CGO_ENABLED environment variable to "0", disabling CGO for Go builds.

Returns:

  • A DaggerEnvVars struct with CGO_ENABLED set to "0".

Example:

envVar := WithGoCgoDisabled()
fmt.Println(envVar) // Output: {Name: "CGO_ENABLED", Value: "0", Expand: false}

func WithGoCgoEnabled

func WithGoCgoEnabled() types.DaggerEnvVars

WithGoCgoEnabled returns a DaggerEnvVars struct that sets the CGO_ENABLED environment variable to "1", enabling CGO for Go builds.

Returns:

  • A DaggerEnvVars struct with CGO_ENABLED set to "1".

Example:

envVar := WithGoCgoEnabled()
fmt.Println(envVar) // Output: {Name: "CGO_ENABLED", Value: "1", Expand: false}

func WithGoPlatform

func WithGoPlatform(platform string) []types.DaggerEnvVars

WithGoPlatform returns a slice of DaggerEnvVars structs that set the GOOS, GOARCH, and optionally GOARM environment variables based on the provided platform string.

Parameters:

  • platform: A string representing the target platform in the format "os/arch[/variant]".

Returns:

  • A slice of DaggerEnvVars structs with GOOS, GOARCH, and optionally GOARM set.

Example:

envVars := WithGoPlatform("linux/amd64")
for _, envVar := range envVars {
    fmt.Println(envVar)
}
// Output:
// {Name: "GOOS", Value: "linux", Expand: false}
// {Name: "GOARCH", Value: "amd64", Expand: false}

envVars = WithGoPlatform("linux/arm/v7")
for _, envVar := range envVars {
    fmt.Println(envVar)
}
// Output:
// {Name: "GOOS", Value: "linux", Expand: false}
// {Name: "GOARCH", Value: "arm", Expand: false}
// {Name: "GOARM", Value: "v7", Expand: false}

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL