Closed handlename closed 9 years ago
Or should I write like this?
package main
import (
"fmt"
"net"
"net/http"
"os"
"github.com/lestrrat/go-server-starter/listener"
)
func main() {
var l net.Listener
// check environment variable
if os.Getenv("SERVER_STARTER_PORT") != "" {
listeners, err := listener.ListenAll()
if err != nil {
fmt.Println(err)
return
}
if 0 < len(listeners) {
l = listeners[0]
}
}
if l == nil {
var err error
l, err = net.Listen("tcp", fmt.Sprintf(":8080"))
if err != nil {
fmt.Println(err)
return
}
}
fmt.Println(http.Serve(l, nil))
}
I think I like your change :)
Thank you!
I want to run app with Server::Starter and without it in same code. So I wrote code like below.
But this code will panic
This Pull Request fix it.