fileUtils

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2020 License: MIT Imports: 4 Imported by: 0

README

Kushuh go file utils

OpenFromProjectRoot

Open a file relative to project root. Especially useful when working with complex project trees, where commands such as tests can run from a sub-directory.

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).

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

FindProjectRoot

Returns the absolute path for the root of a project. It assumes naming conventions, such as only the root folder is named after the project name.

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