lang

Hello World for Go

C/H 2019. 2. 5. 08:30
package main
import (
"fmt"
"net/http"
)
func main() {
// '/'경로 핸들러
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request){
// welcome
fmt.Fprintf(w,"Hello World!")
})
http.HandleFunc("/about", func(w http.ResponseWriter, r *http.Request){
// welcome
fmt.Fprintf(w, "About")
})
http.ListenAndServe(":8080", nil) // 8080 서버시작
}
// go run helloworld.go
// http://localhost:8080
// http://localhost:8080/about
view raw helloworld.go hosted with ❤ by GitHub


반응형

'lang' 카테고리의 다른 글

Revel Frameworkd for Golang  (0) 2019.02.06
IDEs for Go  (0) 2019.02.04
Phantomjs - hello World  (0) 2019.01.28
Golang windows path  (0) 2019.01.15
GetText 로컬라이즈 방법, ko.po, ko.mo  (0) 2016.12.30