LoginSignup
6
4

More than 5 years have passed since last update.

goでWebアプリケーションをつくった話

Posted at

単純なHTTPのコード

main.go

package main

import (
    "log"
    "net/http"
)

func main() {

    http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request ) {
         w.Write([]byte(`
         <html><head><title>ちゃっと</title></head>
         <body>ちゃっと</body>
         </html>
         `))
    })

    if err := http.ListenAndServe(":8080" , nil); err != nil {
        log.Fatal("ListenAndServe:" , err)
    }
}

実行する方法

$ go run main.go
6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4