Skip to content

Commit

Permalink
feat: version使用编译时注入
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Jul 4, 2024
1 parent 63dcb61 commit a6f28ee
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
[TOC]

# Cago

[![godoc](https://godoc.org/github.com/codfrm/cago?status.svg)](https://pkg.go.dev/github.com/codfrm/cago)
[![Go Report Card](https://goreportcard.com/badge/github.com/codfrm/cago)](https://goreportcard.com/report/github.com/codfrm/cago)
[![License](https://img.shields.io/github/license/go-eagle/eagle?style=flat-square)](/LICENSE)

Cago 一个快速开发的集成式框架.使用模块化的开发模式,每一个组件都可以单独的调用.

Cago 只对社区工具进行集成,大大减少迁移难度和学习成本,我们不生产代码,我们只是方案的搬运工.
Expand Down
9 changes: 4 additions & 5 deletions configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import (

type Env string

// Version 编译时注入 -w -s -X github.com/codfrm/cago/configs.Version=1.0.0
var Version = "1.0.0"

const (
DEV Env = "dev"
TEST Env = "test"
Expand Down Expand Up @@ -57,15 +60,11 @@ func NewConfig(appName string, opt ...Option) (*Config, error) {
if err := s.Scan(ctx, "debug", &debug); err != nil {
return nil, err
}
version := ""
if err := s.Scan(ctx, "version", &version); err != nil {
return nil, err
}
c := &Config{
AppName: appName,
Debug: debug,
Env: env,
Version: version,
Version: Version,
source: s,
serialization: options.serialization,
}
Expand Down
1 change: 1 addition & 0 deletions registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ func (r *Cago) RegistryCancel(component ComponentCancel) *Cago {
// 可以通过ctx、cancelFunc和进程信号量来控制整个应用的生命周期
// 停止时会调用 Component.CloseHandle 方法关闭组件,会等待所有组件关闭完成,最终关闭整个应用
func (r *Cago) Start() error {
r.info(r.cfg.AppName + " is starting...")
quitSignal := make(chan os.Signal, 1)
// 优雅启停
signal.Notify(
Expand Down

0 comments on commit a6f28ee

Please sign in to comment.