fileUtils

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2020 License: MIT Imports: 4 Imported by: 0

README

Kushuh go file utils

OpenFromProjectRoot

Open a file relative to project root, when a command is ran from a sub-directory (which happens with tests and some other commands).

It ensures a file opens from project root with go modules, without having to pass it as an ENV variable (like GOPATH does in non module go packages). It assumes the project folder has an unique name in the entire project tree.

file, err := fileUtils.OpenFromProjectRoot(rootFolderName, relativePath)

FindProjectRoot

Returns the absolute path for the root of a project. It assumes the project folder has an unique name in the entire project tree.

path, err := file_utils.FindProjectRoot(rootFolderName)

2020 Kushuh - MIT license

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindProjectRoot

func FindProjectRoot(rootName string) (string, error)

func OpenFromProjectRoot

func OpenFromProjectRoot(root, path string) (*os.File, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL