34 lines
548 B
Go
34 lines
548 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"k8s-example/cmn/conf"
|
|
"k8s-example/hello"
|
|
"net/http"
|
|
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
var (
|
|
version = "1.0.0-local"
|
|
)
|
|
|
|
func main() {
|
|
|
|
// read -f parameter (config file)
|
|
configPath := flag.String("f", ".linux-config.json", "config file")
|
|
flag.Parse()
|
|
conf.Init(*configPath)
|
|
|
|
http.HandleFunc("/hello", hello.Handler)
|
|
|
|
port := viper.GetInt("server.port")
|
|
|
|
fmt.Println("server on :", port, "version:", version)
|
|
err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
}
|