Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
- bitwarden-cli
- bitwarden-secrets-manager
- mise
- mise-golang
- mise-node
- mise-python
- vault
Expand Down Expand Up @@ -64,6 +65,7 @@ jobs:
- bitwarden-secrets-manager
- kamal
- mise
- mise-golang
- mise-node
- mise-python
- vault
Expand Down
25 changes: 25 additions & 0 deletions src/mise-golang/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# Go (mise) (mise-golang)

Installs Go via mise-en-place version manager.

## Example Usage

```json
"features": {
"ghcr.io/RouL/devcontainer-features/mise-golang:1": {}
}
```

## Options

| Options Id | Description | Type | Default Value |
|-----|-----|-----|-----|
| version | Version to be installed as default. | string | latest |
| extra_versions | Additional versions to be installed. (space separated) | string | - |



---

_Note: This file was auto-generated from the [devcontainer-feature.json](https://github.com/RouL/devcontainer-features/blob/main/src/mise-golang/devcontainer-feature.json). Add additional notes to a `NOTES.md`._
21 changes: 21 additions & 0 deletions src/mise-golang/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"id": "mise-golang",
"version": "1.0.0",
"name": "Go (mise)",
"description": "Installs Go via mise-en-place version manager.",
"dependsOn": {
"ghcr.io/RouL/devcontainer-features/mise:latest": {}
},
"options": {
"version": {
"description": "Version to be installed as default.",
"type": "string",
"default": "latest"
},
"extra_versions": {
"description": "Additional versions to be installed. (space separated)",
"type": "string",
"default": ""
}
}
}
45 changes: 45 additions & 0 deletions src/mise-golang/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/bash
set -e

USERNAME="${USERNAME:-"${_REMOTE_USER:-"automatic"}"}"
VERSION="${VERSION:-lts}"

REQUIRED_PACKAGES="git ca-certificates"

apt_get_update()
{
if [ "$(find /var/lib/apt/lists/* | wc -l)" = "0" ]; then
echo "Running apt-get update..."
apt-get update -y
fi
}

check_packages() {
if ! dpkg -s "$@" > /dev/null 2>&1; then
apt_get_update
apt-get -y install --no-install-recommends "$@"
fi
}

export DEBIAN_FRONTEND=noninteractive

check_packages $REQUIRED_PACKAGES

install() {
su ${USERNAME} -c "mise use --global go@${VERSION}"
}

echo "(*) Installing Go (${VERSION}) via mise as default..."

install

for extraVersion in $EXTRA_VERSIONS
do
echo "(*) Installung Go (${extraVersion}) via mise"
su ${USERNAME} -c "mise install go@${VERSION}"
done

# Clean up
rm -rf /var/lib/apt/lists/*

echo "Done!"
8 changes: 8 additions & 0 deletions test/mise-golang/golang1.23.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

source dev-container-features-test-lib

check "check default go == 1.23.*" bash -c "go version | grep -E '^go version go1\\.23\\.'"

reportResults
10 changes: 10 additions & 0 deletions test/mise-golang/golang1.24_golang1.23_golang1.22.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set -e

source dev-container-features-test-lib

check "check default go == 1.24.*" bash -c "go version | grep -E '^go version go1\\.24\\.'"
check "check [email protected]" bash -c "mise exec [email protected] -- go version | grep -E '^go version go1\\.23\\.'"
check "check [email protected]" bash -c "mise exec [email protected] -- go version | grep -E '^go version go1\\.22\\.'"

reportResults
19 changes: 19 additions & 0 deletions test/mise-golang/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"golang1.23": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"mise-golang": {
"version": "1.23"
}
}
},
"golang1.24_golang1.23_golang1.22": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"features": {
"mise-golang": {
"version": "1.24",
"extra_versions": "1.23 1.22"
}
}
}
}
8 changes: 8 additions & 0 deletions test/mise-golang/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

source dev-container-features-test-lib

check "check default go" bash -c "go version | grep -E '^go version go[1-9][0-9]*\\.'"

reportResults