-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
133 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/go/.devcontainer/base.Dockerfile | ||
|
||
# [Choice] Go version: 1, 1.16, 1.17 | ||
ARG VARIANT="1.17" | ||
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT} | ||
|
||
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10 | ||
ARG NODE_VERSION="none" | ||
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi | ||
|
||
# [Optional] Uncomment this section to install additional OS packages. | ||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
# && apt-get -y install --no-install-recommends <your-package-list-here> | ||
|
||
# [Optional] Uncomment the next line to use go get to install anything else you need | ||
# RUN go get -x <your-dependency-or-tool> | ||
|
||
# [Optional] Uncomment this line to install global node packages. | ||
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: | ||
// https://github.com/microsoft/vscode-dev-containers/tree/v0.194.3/containers/go | ||
{ | ||
"name": "Go", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"args": { | ||
// Update the VARIANT arg to pick a version of Go: 1, 1.16, 1.17 | ||
"VARIANT": "1.17", | ||
// Options | ||
"NODE_VERSION": "lts/*" | ||
} | ||
}, | ||
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], | ||
|
||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"go.toolsManagement.checkForUpdates": "local", | ||
"go.useLanguageServer": true, | ||
"go.gopath": "/go", | ||
"go.goroot": "/usr/local/go" | ||
}, | ||
|
||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"golang.Go" | ||
], | ||
|
||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
// "postCreateCommand": "go version", | ||
|
||
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ | |
/mc-server-runner.exe | ||
/*.iml | ||
/.idea/ | ||
/tmp/ | ||
/tmp/ | ||
/.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
//go:build !linux | ||
|
||
package main | ||
|
||
import ( | ||
"go.uber.org/zap" | ||
"io" | ||
) | ||
|
||
func handleNamedPipe(ctx context.Context, path string, stdin io.Writer) error { | ||
// does nothing on non-linux | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package main | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io" | ||
"os" | ||
"syscall" | ||
) | ||
|
||
func handleNamedPipe(ctx context.Context, path string, stdin io.Writer) error { | ||
fi, statErr := os.Stat(path) | ||
if statErr != nil { | ||
if os.IsNotExist(statErr) { | ||
mkErr := syscall.Mkfifo(path, 0666) | ||
if mkErr != nil { | ||
return fmt.Errorf("failed to create named pipe: %w", mkErr) | ||
} | ||
} else { | ||
return fmt.Errorf("failed to stat named pipe: %w", statErr) | ||
} | ||
} else { | ||
// already exists...named pipe? | ||
if fi.Mode().Type()&os.ModeNamedPipe == 0 { | ||
return fmt.Errorf("existing path '%s' is not a named pipe", path) | ||
} | ||
} | ||
|
||
f, openErr := os.Open(path) | ||
if openErr != nil { | ||
return fmt.Errorf("failed to open named pipe: %w", openErr) | ||
} | ||
|
||
go func() { | ||
_, _ = io.Copy(stdin, f) | ||
// copy finished due to file closure (or error) | ||
os.Remove(path) | ||
}() | ||
|
||
go func() { | ||
<-ctx.Done() | ||
// kick the copy operation above | ||
f.Close() | ||
}() | ||
|
||
return nil | ||
} |