github.com/angenalZZZ/gofunc@v0.0.0-20210507121333-48ff1be3917b/data/dir.go (about)

     1  package data
     2  
     3  import (
     4  	"path/filepath"
     5  	"runtime"
     6  	"sync"
     7  
     8  	"github.com/angenalZZZ/gofunc/f"
     9  )
    10  
    11  var (
    12  	// RootDir todo sets application root dir
    13  	RootDir = `A:\test`
    14  	// CurrentDir get current dir
    15  	CurrentDir = f.CurrentDir()
    16  	// CurrentPath get current path
    17  	CurrentPath = f.CurrentPath()
    18  	// CurrentFile get current file name
    19  	CurrentFile = f.CurrentFile()
    20  	// CurrentUserName get computer name - user name
    21  	CurrentUserName = f.CurrentUserName()
    22  	// CurrentUserHomeDir get $HOME
    23  	CurrentUserHomeDir = f.CurrentUserHomeDir()
    24  	// CodeDir get the directory where the current code file is located
    25  	CodeDirname, _ = CodeDirFileLine()
    26  
    27  	// CodeDir get current code dir
    28  	CodeDir = func(codeDir string) string { return filepath.Join(filepath.Dir(CodeDirname), codeDir) }
    29  
    30  	// CodeDirFileLine get current code file name and line number
    31  	CodeDirFileLine = func() (string, int) {
    32  		_, file, line, _ := runtime.Caller(0)
    33  		return filepath.Dir(file), line
    34  	}
    35  
    36  	// Dir get the new directory under the current directory
    37  	Dir = func(name string) string { return filepath.Join(CurrentDir, name) }
    38  
    39  	// Init todo init function
    40  	Init = new(sync.Once).Do
    41  )