-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgolang-example.go
More file actions
executable file
·25 lines (19 loc) · 900 Bytes
/
Copy pathgolang-example.go
File metadata and controls
executable file
·25 lines (19 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env sh
/* 2>/dev/null
DOCKER_IMAGE=golang:alpine
DOCKER_CMD="go run"
## Optionally, un-comment one of these lines to give access to current directory, read-only or read-write:
# DOCKER_EXTRA_ARGS="-w $(pwd) -u $(id -u):$(id -g) -v $(pwd):$(pwd):ro"
# DOCKER_EXTRA_ARGS="-w $(pwd) -u $(id -u):$(id -g) -v $(pwd):$(pwd):rw"
s="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")";ss="${s}.docker-shebang.go";awk "x==1{print}/\*\/$/{x=1}" "$0">"$ss";docker run --rm -a stdin -a stdout -a stderr -i$([ -t 0 ] && echo t) --init -v "$ss":"$s":ro ${DOCKER_EXTRA_ARGS} ${DOCKER_IMAGE} ${DOCKER_CMD} "$s" "$@";e=$?;rm -- "$ss";exit $e
This self-contained script runner for Docker via:
https://github.com/hugojosefson/docker-shebang
*/
package main
import "os"
import "fmt"
func main() {
fmt.Println("Hello world.")
fmt.Println("I was called with arguments:")
fmt.Printf("%#v\n", os.Args)
}