github.com/neatio-net/neatio@v1.7.3-0.20231114194659-f4d7a2226baa/utilities/common/path.go (about)

     1  package common
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"path/filepath"
     7  	"runtime"
     8  )
     9  
    10  func MakeName(name, version string) string {
    11  	return fmt.Sprintf("%s/v%s/%s/%s", name, version, runtime.GOOS, runtime.Version())
    12  }
    13  
    14  func FileExist(filePath string) bool {
    15  	_, err := os.Stat(filePath)
    16  	if err != nil && os.IsNotExist(err) {
    17  		return false
    18  	}
    19  
    20  	return true
    21  }
    22  
    23  func AbsolutePath(Datadir string, filename string) string {
    24  	if filepath.IsAbs(filename) {
    25  		return filename
    26  	}
    27  	return filepath.Join(Datadir, filename)
    28  }