go-program-framework

module
v0.0.0-...-fe2b130 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2020 License: Apache-2.0

README

中文版

go-program-framework

go-log The go-program-framework is established by referring to the engineering architecture of GO source code and my development experience. You can use it as a structural reference for your development of GO projects, and I will constantly improve the toolkit and project✊✊ ⭐⭐⭐⭐⭐

ProgramArch

├── bin	                    // compiled executable binary	
├── configs                // config file
├── doc                    // document for `godoc` view
├── docker                 // DockerFile
├── internal               // private file
├── logs                   // log file
├── scripts                // script files, such as py,js.sh,bat...
└── src                    // go source code
    ├── app                // app for assembly server
    │   └── ops            // diff app version 
    ├── cmd                // go build fold
    │   ├── client         // client
    │   └── server         // server
    ├── internal           // private package,can't improt and view by`godoc`
    └── pkg                // tool package
        ├── app            // define `application` interface
        │   └── testdata   // testdata
        ├── config         // read config file
        ├── log            // create log entity
        └── utils          // base utils

ProgramRename

./scripts/rename.sh your-appname

Makefile

make help

 Choose a command run in go-program-framework:

  compile        Compile the binary of server and client
  build-server   build server
  build-client   build client
  build          build client and server
  clean-server   clean server
  clean-client   clean client
  clean          clean server and client
  start-server   start server
  start-client   start client
  godoc          start godoc server, 127.0.0.1            6060
  wire           go wire
  di-clean       docker image clean
  d-clean        docker clean
  d-build        docker build
  md             rename readme

make godoc

make godoc run local http server,http://127.0.0.1:6060. you can browse urls like.

http://127.0.0.1:6060/pkg/   // 依赖的包名, ./src/internal 不可访问
http://127.0.0.1:6060/doc/   // 就是 ./doc/

DockerFile

In order to drop the dependency in the container, the local .ssh file can be copied to the container for construction. However, after the construction, the image capacity is too large and there is code leakage. We can use multi-stage deployment to solve these problems

pkg pakage

pkg package defines the server interface. As long as your expansion package implements these interfaces, you can register unlimited services, use wire to automate dependency injection, and smoothly exit the application after receiving the exit signal

// Server define register server interface
type Server interface {
	Desc() string
	Start() error
	Stop() error
}

Application_Example

==Note that you are required to provide the basic configuration file as follows==

app:
  name: your-app-name
  
log: 
  filename: /tmp/your-app-name.log
  maxSize: 500
  maxBackups: 3
  maxAge: 3
  level: debug
  stdout: true

welcome to the issues ✊✊✊

Directories

Path Synopsis
src
cmd/client
Package main is client main is server entry point
Package main is client main is server entry point
cmd/server
Package main is server main is server entry point
Package main is server main is server entry point
internal
Package internal is unview to other
Package internal is unview to other
pkg
Package pkg implements common functions.
Package pkg implements common functions.
pkg/app
Package app define the App interface NOTE: your config like [app.yaml] if you use the package app: name: your-app-name log: filename: /tmp/your-app-name.log maxSize: 500 maxBackups: 3 maxAge: 3 level: debug stdout: true
Package app define the App interface NOTE: your config like [app.yaml] if you use the package app: name: your-app-name log: filename: /tmp/your-app-name.log maxSize: 500 maxBackups: 3 maxAge: 3 level: debug stdout: true

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL