This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
type NewApp struct { | |
Port int | |
Debug bool | |
} | |
func (appCfg NewApp) Create() *App { | |
a := &App{ | |
Cfg: appCfg, | |
} | |
return a | |
} | |
type App struct { | |
Cfg NewApp | |
} | |
func (app *App) Run() { | |
fmt.Printf("app is runnning on port %d\n", app.Cfg.Port) | |
} | |
func main() { | |
myApp := NewApp{Debug: false, Port: 8080}.Create() | |
myApp.Run() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment