Show git commit version on startup
This commit is contained in:
		
							
								
								
									
										13
									
								
								main.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								main.go
									
									
									
									
									
								
							| @@ -10,6 +10,7 @@ import ( | |||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"os" | 	"os" | ||||||
| 	"path" | 	"path" | ||||||
|  | 	"runtime/debug" | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"sync" | 	"sync" | ||||||
| @@ -51,7 +52,17 @@ func main() { | |||||||
|  |  | ||||||
| 	glist.DataPath = dataPath | 	glist.DataPath = dataPath | ||||||
|  |  | ||||||
| 	log.Printf("Grocery List bot starting with datapath:%s, port:%d\n", dataPath, port) | 	commit := "unknown" | ||||||
|  |  | ||||||
|  | 	if bi, ok := debug.ReadBuildInfo(); ok { | ||||||
|  | 		for _, s := range bi.Settings { | ||||||
|  | 			if s.Key == "vcs.revision" { | ||||||
|  | 				commit = s.Value[:8] | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	log.Printf("Grocery List bot (%s) starting with datapath:%s, port:%d\n", commit, dataPath, port) | ||||||
|  |  | ||||||
| 	var chats sync.Map | 	var chats sync.Map | ||||||
| 	if err := loadData(dataPath, &chats); err != nil { | 	if err := loadData(dataPath, &chats); err != nil { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user