Skip to content

haodreams/goversion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

goversion

  1. 编译goversion

  2. 改名 %GOROOT%\bin\go.exe ==> %GOROOT%\bin\goo.exe

  3. 复制goversion.exe ==> %GOROOT%\bin\goversion.exe

  4. 改名 %GOROOT%\bin\goversion.exe ==> %GOROOT%\bin\go.exe

  5. 添加以下代码到项目包main

========

var (
	buildDate string	
	gitDate   string	
	gitCommit string	
)
func version() {
	if buildDate != "" {	
		fmt.Println("Build date:", buildDate)		
	}	
	if gitDate != "" {	
		fmt.Println("Git date:", gitDate)		
	}	
	if gitCommit != "" {	
		fmt.Println("Git version:", gitCommit)		
	}	
}


示例:

package main

import (
	"fmt"		
)

var (
	buildDate string	
	gitDate   string	
	gitCommit string	
)
func version() {
	if buildDate != "" {	
		fmt.Println("Build date:", buildDate)		
	}	
	if gitDate != "" {	
		fmt.Println("Git date:", gitDate)		
	}	
	if gitCommit != "" {	
		fmt.Println("Git version:", gitCommit)		
	}	
}

func main() {
	version()	
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages