path

package
v0.0.0-...-c859fe7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2015 License: MIT Imports: 1 Imported by: 0

README

Path

This package contains functions that deal with paths. Right now there's only the FindRoot function. An example:

package main

import (
	"fmt"

	"github.com/mssola/go-utils/path"
)

func main() {
	base := path.FindRoot("mssola", "/home/mssola/another/mssola/dir")
	fmt.Printf("%v\n", base) // => /home/mssola/another/mssola

	// We can also specify the current path with a ".".
	// In this example image that the current pwd is "/home/mssola/test"
	base = path.FindRoot("mssola", ".")
	fmt.Printf("%v\n", base) // => /home/mssola
}

Copyright © 2014-2015 Miquel Sabaté Solà, released under the MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindRoot

func FindRoot(root, current string) string

Public: get the first absolute path that has the "root" parameter as its root from the perspective of the "current" path. The current path can be relative (e.g. "." is an accepted value). The returned path has no trailing slashes. Note that if no path was found, then "/" will be returned.

Example:

    FindRoot("mssola", "/home/mssola/another/mssola/dir")
-> returns "/home/mssola/another/mssola"

Returns a string containing the absolute path matching the confitions. Note that this works on UNIX systems. I haven't tested this on Windows.

Types

This section is empty.

Jump to

Keyboard shortcuts

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