Skip to content

Golang package that allows a global filepath to be initialized, which can then be used from other packages.

License

Notifications You must be signed in to change notification settings

theTardigrade/golang-globalFilepath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

golang-globalFilepath

This package allows a global filepath to be initialized, which can then be used from other packages.

Example

package main

import (
	"fmt"

	gf "github.com/theTardigrade/golang-globalFilepath"
)

func main() {
	// initializes the base path as the path to the "models" subdirectory of the
	// "data" subdirectory of the directory where this package is located
	gf.Init("data", "models")

	// prints the base path
	fmt.Println(gf.Get())

	// prints the path to the "z" subdirectory of the "y" subdirectory of the
	// "x" subdirectory of the base path
	fmt.Println(gf.Join("x", "y", ".", "z"))

	// reinitializes the base path to the directory where this package is located
	gf.Init()

	// prints path to the directory above the base path
	fmt.Println(gf.Join(".."))
}

About

Golang package that allows a global filepath to be initialized, which can then be used from other packages.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages