package main

import (
	"flag"
	"fmt"
	"go-example/cmn/conf"
	"go-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.yaml", "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)
	}
}
