Move to gopath dir and introduce new package
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package hello
|
||||
|
||||
import ()
|
||||
|
||||
// Hello writes a welcome string
|
||||
func Hello() string {
|
||||
return "Hello golang!"
|
||||
}
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user