From 6ce8b89114da3f3fc47ac8dbd945ae35e8bff602 Mon Sep 17 00:00:00 2001 From: Alexander Krieg Date: Sat, 15 Jun 2019 09:44:29 +0000 Subject: [PATCH] Move to gopath dir and introduce new package --- .../microsoft/vscode-remote-try-go/hello/hello.go | 8 ++++++++ .../microsoft/vscode-remote-try-go/main/server.go | 7 ++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 src/github.com/microsoft/vscode-remote-try-go/hello/hello.go rename server.go => src/github.com/microsoft/vscode-remote-try-go/main/server.go (75%) diff --git a/src/github.com/microsoft/vscode-remote-try-go/hello/hello.go b/src/github.com/microsoft/vscode-remote-try-go/hello/hello.go new file mode 100644 index 0000000..f0b1780 --- /dev/null +++ b/src/github.com/microsoft/vscode-remote-try-go/hello/hello.go @@ -0,0 +1,8 @@ +package hello + +import () + +// Hello writes a welcome string +func Hello() string { + return "Hello golang!" +} diff --git a/server.go b/src/github.com/microsoft/vscode-remote-try-go/main/server.go similarity index 75% rename from server.go rename to src/github.com/microsoft/vscode-remote-try-go/main/server.go index 90bfbb3..ee37faa 100644 --- a/server.go +++ b/src/github.com/microsoft/vscode-remote-try-go/main/server.go @@ -7,17 +7,18 @@ package main import ( "fmt" + "github.com/microsoft/vscode-remote-try-go/hello" "io" "net/http" ) -func hello(w http.ResponseWriter, r *http.Request) { - io.WriteString(w, "Hello remote world!") +func helloOld(w http.ResponseWriter, r *http.Request) { + io.WriteString(w, hello.Hello()) } func main() { portNumber := "9000" - http.HandleFunc("/", hello) + http.HandleFunc("/", helloOld) fmt.Println("Server listening on port ", portNumber) http.ListenAndServe(":"+portNumber, nil) }