Skip to content

Instantly share code, notes, and snippets.

@tMinamiii
Last active August 3, 2023 03:35
Show Gist options
  • Save tMinamiii/730d89ca3c79efc8c200e1a1d8a41ace to your computer and use it in GitHub Desktop.
Save tMinamiii/730d89ca3c79efc8c200e1a1d8a41ace to your computer and use it in GitHub Desktop.
envrc
export ENV=local
if [ ${ENV} = "test" ]; then
source ./.test.env
elif [ ${ENV} = "local" ]; then
source ./.local.env
fi
export DYNAMODB_LOCAL_PORT
export DYNAMODB_LOCAL_ADMIN_PORT
export DYNAMODB_LOCAL_ENDPOINT
export COGNITO_LOCAL_PORT
export COGNITO_LOCAL_ENDPOINT
export COGNITO_LOCAL_CODE
export AUTH_API_SLS_HTTP_PORT
export AUTH_API_SLS_LAMBDA_PORT
export GO_VERSION=$(curl -s -XGET "https://go.dev/dl/?mode=json" | jq ".[] | select (.version | startswith(\"go1.20\")) | .files[] | select (.os == \"darwin\" and .arch == \"$(uname -m)\") | select(.filename | endswith(\"tar.gz\")) | .version" | tr -d '"')
if [ -d "${HOME}/sdk/${GO_VERSION}" ]; then
export GOROOT="${HOME}/sdk/${GO_VERSION}"
exit 0
fi
/usr/local/go/bin/go install golang.org/dl/${GO_VERSION}@latest
${GO_VERSION} download
export GOPATH="${HOME}/go"
export PATH="${HOME}/sdk/${GO_VERSION}/bin:$PATH"
export GOROOT="${HOME}/sdk/${GO_VERSION}"
export GO_VERSION
go_version_path=$(find . -name .go-version)
if [ -e "${go_version_path}" ]; then
GO_VERSION=$(cat ${go_version_path})
else
# use go.mod
GO_VERSION=$(curl -s -XGET "https://go.dev/dl/?mode=json" | jq ".[] | select (.version | startswith(\"go1.20\")) | .files[] | select (.os == \"darwin\" and .arch == \"$(uname -m)\") | select(.filename | endswith(\"tar.gz\")) | .version" | tr -d '"')
fi
if [ -d "${HOME}/sdk/${GO_VERSION}" ]; then
export GOROOT="${HOME}/sdk/${GO_VERSION}"
exit 0
fi
/usr/local/go/bin/go install golang.org/dl/${GO_VERSION}@latest
${GO_VERSION} download
export GOPATH="${HOME}/go"
export PATH="${HOME}/sdk/${GO_VERSION}/bin:$PATH"
export GOROOT="${HOME}/sdk/${GO_VERSION}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment