github.com/gagliardetto/golang-go@v0.0.0-20201020153340-53909ea70814/cmd/link/internal/ld/testdata/httptest/main/main.go (about)

     1  // A small test program that uses the net/http package. There is
     2  // nothing special about net/http here, this is just a convenient way
     3  // to pull in a lot of code.
     4  
     5  package main
     6  
     7  import (
     8  	"net/http"
     9  	"net/http/httptest"
    10  )
    11  
    12  type statusHandler int
    13  
    14  func (h *statusHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
    15  	w.WriteHeader(int(*h))
    16  }
    17  
    18  func main() {
    19  	status := statusHandler(http.StatusNotFound)
    20  	s := httptest.NewServer(&status)
    21  	defer s.Close()
    22  }