fs

package
v0.0.0-...-ff11b4d Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2015 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package fs provides utility functions to work with sources files relate to standard golang workspace. It's using GOROOT and GOHOME environment variables to search.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPackagePath

func GetPackagePath(dirPath string) string

GetPackagePath return relative path to standard go workspace layout - GOPATH/src and GOROOT/src and trims file name if it presents.

func GetRelativePath

func GetRelativePath(path string) string

GetRelativePath returns relative path to $GOPATH or $GOROOT env variable.

func GetUnusedSources

func GetUnusedSources(pkg string, fset *token.FileSet) ([]string, error)

GetUnusedSources returns list of source files in package that are not presenting in the file set

func ReplaceStringInFile

func ReplaceStringInFile(file string, offset int, from string, to string) error

ReplaceStringInFile replaces string in the file at the given offset. There are next steps to do that: * Storing the content that starts after replacing string * Truncate file from the offset * Append new string * Append rest of the file that was stored on the first step

func SourceFiles

func SourceFiles(pkg string, deep bool) ([]string, error)

GetFiles returns all golang source files which is inside a package. A path to the package is constructing using standard workspace layout - $GOPATH/src. All tests files are ignored. If deep flag is true then will return files from all subpackages as well. It collects only files that name ends with .go extension. Returns list of full file names.

Types

This section is empty.

Jump to

Keyboard shortcuts

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