Convert tabs to spaces and force go fmt

This commit is contained in:
Leonid Bugaev
2014-10-13 18:05:16 +04:00
parent 9e63fb5b36
commit 1637dd491f
21 changed files with 702 additions and 704 deletions
+34 -34
View File
@@ -1,63 +1,63 @@
package main
import (
"net"
"net/http"
"log"
"net/http/httputil"
"log"
"net"
"net/http"
"net/http/httputil"
)
type HTTPInput struct {
data chan []byte
address string
listener net.Listener
data chan []byte
address string
listener net.Listener
}
func NewHTTPInput(address string) (i *HTTPInput) {
i = new(HTTPInput)
i.data = make(chan []byte)
i.address = address
i = new(HTTPInput)
i.data = make(chan []byte)
i.address = address
i.listen(address)
i.listen(address)
return
return
}
func (i *HTTPInput) Read(data []byte) (int, error) {
buf := <-i.data
copy(data, buf)
buf := <-i.data
copy(data, buf)
return len(buf), nil
return len(buf), nil
}
func (i *HTTPInput) handler(w http.ResponseWriter, r *http.Request) {
buf, _ := httputil.DumpRequest(r, true)
func (i *HTTPInput) handler(w http.ResponseWriter, r *http.Request) {
buf, _ := httputil.DumpRequest(r, true)
i.data <- buf
i.data <- buf
http.Error(w, http.StatusText(200), 200)
http.Error(w, http.StatusText(200), 200)
}
func (i *HTTPInput) listen(address string) {
var err error
var err error
mux := http.NewServeMux()
mux := http.NewServeMux()
mux.HandleFunc("/", i.handler)
mux.HandleFunc("/", i.handler)
i.listener, err = net.Listen("tcp", address)
if err != nil {
log.Fatal("HTTP input listener failure:", err)
}
go func(){
err = http.Serve(i.listener, mux)
if err != nil {
log.Fatal("HTTP input serve failure:", err)
}
}()
i.listener, err = net.Listen("tcp", address)
if err != nil {
log.Fatal("HTTP input listener failure:", err)
}
go func() {
err = http.Serve(i.listener, mux)
if err != nil {
log.Fatal("HTTP input serve failure:", err)
}
}()
}
func (i *HTTPInput) String() string {
return "HTTP input: " + i.address
return "HTTP input: " + i.address
}