From d68bbbd16bdd8ba639130bbed4b60c3016df0681 Mon Sep 17 00:00:00 2001 From: uta-mori Date: Tue, 28 Jul 2020 13:21:40 +0900 Subject: [PATCH 1/6] more simplify structure --- {src/hello => hello}/hello.go | 2 -- src/main/server.go => server.go | 5 +++-- 2 files changed, 3 insertions(+), 4 deletions(-) rename {src/hello => hello}/hello.go (96%) rename src/main/server.go => server.go (89%) diff --git a/src/hello/hello.go b/hello/hello.go similarity index 96% rename from src/hello/hello.go rename to hello/hello.go index 323b848..db44cd1 100644 --- a/src/hello/hello.go +++ b/hello/hello.go @@ -1,7 +1,5 @@ package hello -import () - // User user type type User struct { ID int64 diff --git a/src/main/server.go b/server.go similarity index 89% rename from src/main/server.go rename to server.go index 2afa31f..376c8db 100644 --- a/src/main/server.go +++ b/server.go @@ -7,9 +7,10 @@ package main import ( "fmt" - "hello" "io" "net/http" + + "github.com/microsoft/vscode-remote-try-go/hello" ) func handle(w http.ResponseWriter, r *http.Request) { @@ -17,7 +18,7 @@ func handle(w http.ResponseWriter, r *http.Request) { } func main() { - portNumber := "9000" + portNumber := "5000" http.HandleFunc("/", handle) fmt.Println("Server listening on port ", portNumber) http.ListenAndServe(":"+portNumber, nil) From 21c0264fc5735a2060d563b6cc710e3d5d933588 Mon Sep 17 00:00:00 2001 From: uta-mori Date: Tue, 28 Jul 2020 13:22:01 +0900 Subject: [PATCH 2/6] mod init github.com/microsoft/vscode-remote-try-go --- go.mod | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..7ce40cf --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/microsoft/vscode-remote-try-go + +go 1.14 From 86b970f35abbbf566905d4e5a26538c970e75c16 Mon Sep 17 00:00:00 2001 From: uta-mori Date: Tue, 28 Jul 2020 13:22:55 +0900 Subject: [PATCH 3/6] Go Modules migration --- .devcontainer/Dockerfile | 30 ++++---------- .devcontainer/devcontainer.json | 73 +++++++++++++++++++++------------ .vscode/launch.json | 4 +- .vscode/settings.json | 4 +- 4 files changed, 58 insertions(+), 53 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index b7b7a97..06acfe6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Update the VARIANT arg in devcontainer.json to pick an Go version -ARG VARIANT=1 +ARG VARIANT=1.14 FROM golang:${VARIANT} # This Dockerfile adds a non-root user with sudo access. Update the “remoteUser” property in @@ -27,17 +27,17 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # Install Go tools + +ENV GO111MODULE=on + ARG GO_TOOLS_WITH_MODULES="\ golang.org/x/tools/gopls \ honnef.co/go/tools/... \ golang.org/x/tools/cmd/gorename \ golang.org/x/tools/cmd/goimports \ golang.org/x/tools/cmd/guru \ - golang.org/x/lint/golint \ - github.com/mdempsky/gocode \ github.com/cweill/gotests/... \ github.com/haya14busa/goplay/cmd/goplay \ - github.com/sqs/goreturns \ github.com/josharian/impl \ github.com/davidrjenni/reftools/cmd/fillstruct \ github.com/uudashr/gopkgs/v2/cmd/gopkgs \ @@ -49,29 +49,13 @@ ARG GO_TOOLS_WITH_MODULES="\ github.com/fatih/gomodifytags \ github.com/mgechev/revive \ github.com/go-delve/delve/cmd/dlv" -RUN mkdir -p /tmp/gotools \ - && cd /tmp/gotools \ - && export GOPATH=/tmp/gotools \ - # Go tools w/module support - && export GO111MODULE=on \ - && (echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get -x )2>&1 \ - # gocode-gomod - && export GO111MODULE=auto \ - && go get -x -d github.com/stamblerre/gocode 2>&1 \ - && go build -o gocode-gomod github.com/stamblerre/gocode \ + +RUN (echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get )2>&1 \ # golangci-lint && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1 \ - # Move Go tools into path and clean up - && mv /tmp/gotools/bin/* /usr/local/bin/ \ - && mv gocode-gomod /usr/local/bin/ \ - && rm -rf /tmp/gotools - -ENV GO111MODULE=auto - # [Optional] Uncomment the next line to use go get to install anything else you need # RUN go get -x - # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update \ # && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends \ No newline at end of file +# && apt-get -y install --no-install-recommends diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9b656b4..3938c28 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,31 +1,52 @@ { - "name": "Go", - "build": { - "dockerfile": "Dockerfile", - // Update the VARIANT arg to pick a version of Go - "args": { "VARIANT": "1" } - }, - "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], + "name": "Go", + "build": { + "dockerfile": "Dockerfile", + // Update the VARIANT arg to pick a version of Go + "args": { "VARIANT": "1.14" } + }, + "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "go.gopath": "/go", - "go.inferGopath": true, - "go.useLanguageServer": true - }, - - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "golang.Go" - ], + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "go.useLanguageServer": true, + "[go]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + // Optional: Disable snippets, as they conflict with completion ranking. + "editor.snippetSuggestions": "none" + }, + "[go.mod]": { + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + } + }, + "gopls": { + // Add parameter placeholders when completing a function. + "usePlaceholders": true, + // the completion engine is allowed to make suggestions for packages that you do not currently import. + "completeUnimported": true, - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [9000], + // If true, enable additional analyses with staticcheck. + // Warning: This will significantly increase memory usage. + "staticcheck": true + }, + "go.lintTool": "golangci-lint" + }, - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "go version", + // Add the IDs of extensions you want installed when the container is created. + "extensions": ["golang.Go"], - // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" -} \ No newline at end of file + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [9000], + + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", + + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} diff --git a/.vscode/launch.json b/.vscode/launch.json index a99da60..01f10d4 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -6,7 +6,7 @@ "type": "go", "request": "launch", "mode": "debug", - "program": "${workspaceFolder}/src/main/server.go" + "program": "${workspaceFolder}/server.go" } ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 5672a16..d26b1bb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { "go.useLanguageServer": true, - "go.inferGopath": true -} \ No newline at end of file + "go.inferGopath": false +} From 8009f7e72b142dd493018aa218bb99e1e1047cff Mon Sep 17 00:00:00 2001 From: uta-mori Date: Tue, 28 Jul 2020 13:28:23 +0900 Subject: [PATCH 4/6] fix typo --- .devcontainer/Dockerfile | 2 +- server.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 06acfe6..4f1b696 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -52,7 +52,7 @@ ARG GO_TOOLS_WITH_MODULES="\ RUN (echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get )2>&1 \ # golangci-lint - && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1 \ + && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1 # [Optional] Uncomment the next line to use go get to install anything else you need # RUN go get -x # [Optional] Uncomment this section to install additional OS packages. diff --git a/server.go b/server.go index 376c8db..28dbdb4 100644 --- a/server.go +++ b/server.go @@ -18,7 +18,7 @@ func handle(w http.ResponseWriter, r *http.Request) { } func main() { - portNumber := "5000" + portNumber := "9000" http.HandleFunc("/", handle) fmt.Println("Server listening on port ", portNumber) http.ListenAndServe(":"+portNumber, nil) From a70b904d4bf2083686e348f298b0f9f1aa5d351f Mon Sep 17 00:00:00 2001 From: uta-mori Date: Wed, 29 Jul 2020 19:57:06 +0900 Subject: [PATCH 5/6] restore 216335b --- .devcontainer/Dockerfile | 32 +++++++++++---- .devcontainer/devcontainer.json | 73 ++++++++++++--------------------- .vscode/settings.json | 2 +- 3 files changed, 51 insertions(+), 56 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4f1b696..b7b7a97 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,5 +1,5 @@ # Update the VARIANT arg in devcontainer.json to pick an Go version -ARG VARIANT=1.14 +ARG VARIANT=1 FROM golang:${VARIANT} # This Dockerfile adds a non-root user with sudo access. Update the “remoteUser” property in @@ -27,17 +27,17 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* # Install Go tools - -ENV GO111MODULE=on - ARG GO_TOOLS_WITH_MODULES="\ golang.org/x/tools/gopls \ honnef.co/go/tools/... \ golang.org/x/tools/cmd/gorename \ golang.org/x/tools/cmd/goimports \ golang.org/x/tools/cmd/guru \ + golang.org/x/lint/golint \ + github.com/mdempsky/gocode \ github.com/cweill/gotests/... \ github.com/haya14busa/goplay/cmd/goplay \ + github.com/sqs/goreturns \ github.com/josharian/impl \ github.com/davidrjenni/reftools/cmd/fillstruct \ github.com/uudashr/gopkgs/v2/cmd/gopkgs \ @@ -49,13 +49,29 @@ ARG GO_TOOLS_WITH_MODULES="\ github.com/fatih/gomodifytags \ github.com/mgechev/revive \ github.com/go-delve/delve/cmd/dlv" - -RUN (echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get )2>&1 \ +RUN mkdir -p /tmp/gotools \ + && cd /tmp/gotools \ + && export GOPATH=/tmp/gotools \ + # Go tools w/module support + && export GO111MODULE=on \ + && (echo "${GO_TOOLS_WITH_MODULES}" | xargs -n 1 go get -x )2>&1 \ + # gocode-gomod + && export GO111MODULE=auto \ + && go get -x -d github.com/stamblerre/gocode 2>&1 \ + && go build -o gocode-gomod github.com/stamblerre/gocode \ # golangci-lint - && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1 + && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /usr/local/bin 2>&1 \ + # Move Go tools into path and clean up + && mv /tmp/gotools/bin/* /usr/local/bin/ \ + && mv gocode-gomod /usr/local/bin/ \ + && rm -rf /tmp/gotools + +ENV GO111MODULE=auto + # [Optional] Uncomment the next line to use go get to install anything else you need # RUN go get -x + # [Optional] Uncomment this section to install additional OS packages. # RUN apt-get update \ # && export DEBIAN_FRONTEND=noninteractive \ -# && apt-get -y install --no-install-recommends +# && apt-get -y install --no-install-recommends \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3938c28..9b656b4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,52 +1,31 @@ { - "name": "Go", - "build": { - "dockerfile": "Dockerfile", - // Update the VARIANT arg to pick a version of Go - "args": { "VARIANT": "1.14" } - }, - "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + "name": "Go", + "build": { + "dockerfile": "Dockerfile", + // Update the VARIANT arg to pick a version of Go + "args": { "VARIANT": "1" } + }, + "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined" ], - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "go.useLanguageServer": true, - "[go]": { - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.organizeImports": true - }, - // Optional: Disable snippets, as they conflict with completion ranking. - "editor.snippetSuggestions": "none" - }, - "[go.mod]": { - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.organizeImports": true - } - }, - "gopls": { - // Add parameter placeholders when completing a function. - "usePlaceholders": true, - // the completion engine is allowed to make suggestions for packages that you do not currently import. - "completeUnimported": true, + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash", + "go.gopath": "/go", + "go.inferGopath": true, + "go.useLanguageServer": true + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "golang.Go" + ], - // If true, enable additional analyses with staticcheck. - // Warning: This will significantly increase memory usage. - "staticcheck": true - }, - "go.lintTool": "golangci-lint" - }, + // Use 'forwardPorts' to make a list of ports inside the container available locally. + "forwardPorts": [9000], - // Add the IDs of extensions you want installed when the container is created. - "extensions": ["golang.Go"], + // Use 'postCreateCommand' to run commands after the container is created. + // "postCreateCommand": "go version", - // Use 'forwardPorts' to make a list of ports inside the container available locally. - "forwardPorts": [9000], - - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "go version", - - // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. - "remoteUser": "vscode" -} + // Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root. + "remoteUser": "vscode" +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index d26b1bb..c24e64f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { "go.useLanguageServer": true, "go.inferGopath": false -} +} \ No newline at end of file From 9b8138630b6a693209788e1c193aefd572c95242 Mon Sep 17 00:00:00 2001 From: uta-mori Date: Wed, 29 Jul 2020 19:59:13 +0900 Subject: [PATCH 6/6] restore 216335b settings.json --- .vscode/settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index c24e64f..5672a16 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,4 @@ { "go.useLanguageServer": true, - "go.inferGopath": false + "go.inferGopath": true } \ No newline at end of file