Understanding Go's net package-Day 1-

12/27 update

Understanding Go's net package-Day 2- I wrote

Introduction

Among the Go packages, I will study the net package, which is one of the packages that I am not good at.

What is a net package?

The net package provides a portable interface to Unix network sockets, including TCP/IP, UDP, domain name resolution, and UNIX domain sockets. Quote: http://golang.jp/pkg/net

Start the server for the time being

main.go


package main

import (
	"fmt"
	"net/http"
)

func main() {
	http.HandleFunc("/", handler)
	http.ListenAndServe(":8080", nil)
}

func handler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprint(w, "Hello World")
}

Now when you access port 8080, you should see Hello World.

Once here,

Recommended Posts

Understanding Go's net package-Day 1-
Understanding Go's net package-Day 2-