github.com/decred/dcrlnd@v0.7.6/assets/assets.go (about)

     1  package assets
     2  
     3  import (
     4  	"path/filepath"
     5  	"runtime"
     6  )
     7  
     8  var basepath string
     9  
    10  func init() {
    11  	_, goFilename, _, _ := runtime.Caller(0)
    12  	basepath = filepath.Dir(goFilename)
    13  }
    14  
    15  // Path returns the absolute filepath of a file in the dcrlnd main module,
    16  // relative to the assets package.
    17  //
    18  // For example, to access the filepath of a sample-dcrlnd.conf file from the
    19  // root of the main module, call Path("../sample-dcrlnd.conf").
    20  //
    21  // This function is only usable when built without -trimpath and on the host the
    22  // Go program was compiled on.
    23  func Path(asset string) string {
    24  	return filepath.Join(basepath, asset)
    25  }