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

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