Skip to content

Commit cf94c07

Browse files
committed
feat: cambie el mensaje cuando corres la app en desarrollo issue gophers-latam#2
Y tambien agregue un separador en el binario cuando lo compilas, entre la version que obtenemos del tag y el nombre del binario tenemos un '-' Signed-off-by: Gabriel Pozo <[email protected]>
1 parent c0ef0ba commit cf94c07

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

Makefile

+1-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ BINARY=minimalchi
33
Version=`git tag -l | tail -1`
44
GitStatus=`git status -s`
55
BuildTime=`date +%FT%T%z`
6-
BuildGoVersion=`go version`
7-
86

97
LDFLAGS=-ldflags "-w -s \
108
-X 'main.BinVersion=${Version}' \
119
-X 'main.GitStatus=${GitStatus}' \
1210
-X 'main.BuildTime=${BuildTime}' \
13-
-X 'main.BuildGoVersion=${BuildGoVersion}' \
1411
"
1512

1613
d:
@@ -28,7 +25,7 @@ run:
2825
go run main.go serve
2926

3027
compile:
31-
CGO_ENABLED=0 go build -o releases/linux/${BINARY}${Version} ${LDFLAGS}
28+
CGO_ENABLED=0 go build -o releases/linux/${BINARY}'-'${Version} ${LDFLAGS}
3229

3330
clean:
3431
if [ -f releases/linux/${BINARY}${Version} ] ; then rm releases/linux/${BINARY}${Version}; fi

cmd/help.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ package cmd
22

33
import (
44
"fmt"
5-
6-
"github.com/gophers-latam/minimal-chi/internal/provider"
75
)
86

97
func RunHelp() {
10-
appName := provider.GetContainer().Config().APPName
118

12-
fmt.Printf(`%s es la plantilla mínima para crear apis propuesta por la comunidad Gophers Latam usando al router chi.
9+
fmt.Printf(`Es la plantilla mínima para crear apis propuesta por la comunidad Gophers Latam usando al router chi.
1310
1411
Comandos:
1512
@@ -26,5 +23,5 @@ $go run ./main.go help
2623
Flags:
2724
2825
(Ud. debería definir aquí sus flags si su aplicación los necesita)
29-
`, appName)
26+
`)
3027
}

main.go

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"fmt"
55
"os"
6+
"runtime"
67
"strings"
78
_ "time/tzdata"
89

@@ -13,16 +14,13 @@ import (
1314
var (
1415
// BinVersion guarda la versión actual del binario de esta aplicación.
1516
// Normalmente la versión es el último git tag
16-
BinVersion string
17+
BinVersion string = "desarrollo"
1718

1819
// GitStatus guarda info acer del estado del repo git
1920
GitStatus string
2021

2122
// BuildTime almacena la fecha de compilación del binario
22-
BuildTime string
23-
24-
// BuildGoVersion indica la versión de go usada para compilar este binario
25-
BuildGoVersion string
23+
BuildTime string = "fecha de compilación"
2624
)
2725

2826
func init() {
@@ -43,6 +41,7 @@ func main() {
4341
// selectCmds Ejecuta los commands alojados en cmd/ según segundo parámetro de cli
4442
func selectCmds() func() {
4543

44+
fmt.Printf("%s version %s Build with Go %v at %v\n\n", provider.GetContainer().Config().APPName, BinVersion, runtime.Version(), BuildTime)
4645
if len(os.Args) == 1 {
4746
fmt.Printf("Ud. debería ejecutar esta aplicación con un comando.\n\n")
4847

@@ -52,7 +51,6 @@ func selectCmds() func() {
5251
// os.Args = []string{"", "serve", "-config=./config_example.yml", "-port=4999", "-log=\"./b.b\"", "-development"}
5352
switch c := os.Args[1]; c {
5453
case "serve":
55-
fmt.Printf("%s version %s Build with Go %v at %v\n", provider.GetContainer().Config().APPName, BinVersion, BuildGoVersion, BuildTime)
5654
return cmd.RunServe
5755
case "help":
5856
return cmd.RunHelp

0 commit comments

Comments
 (0)