gitee.com/quant1x/gox@v1.21.2/logger/application.go (about)

     1  package logger
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"strings"
     7  	"sync"
     8  )
     9  
    10  var (
    11  	onceApp         sync.Once
    12  	applicationName = ""
    13  )
    14  
    15  func lazyLoadApplication() {
    16  	path, _ := os.Executable()
    17  	_, exec := filepath.Split(path)
    18  	arr := strings.Split(exec, ".")
    19  	applicationName = arr[0]
    20  }
    21  
    22  // ApplicationName 获取执行文件名
    23  func ApplicationName() string {
    24  	onceApp.Do(lazyLoadApplication)
    25  	return applicationName
    26  }