Skip to content

jaredwarren/app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APP

Super simple base web application. I just got tired of copying the same code to every project.

config

Config Format

server:
  name: Host # Name/Title of web service
  host: 127.0.0.1 # TCP address to listen on
  port: 8081 # TCP port to listen on

# Native Config Options
ui:
  show: true
  width: 600
  height: 600

Load

// load config
	viper.SetConfigName("config_" + runtime.GOOS)
	viper.AddConfigPath(".")
	if err := viper.ReadInConfig(); err != nil {
		log.Fatalf("Error reading config file, %s", err)
	}

	var serverConfig app.Config
	viper.UnmarshalKey("server", &serverConfig)
	fmt.Printf("%+v\n", serverConfig)

Usage

Web

    conf := &app.WebConfig{
		Host: "127.0.0.1",
		Port: 8084,
	}
	a := app.NewWeb(conf)
	service.Register(a)
	d := <-a.Exit

Native

    app := app.NewNative(nil)
    defer app.Close()
    service.Register(app.Service)
    app.Run()
    done := <-app.Exit
    if done != nil {
        fmt.Println("Something Happened, Bye!", done)
    } else {
        fmt.Println("Good Bye!")
    }

About

Go web or native app framework.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages