gas

package module
v0.0.0-...-200a9ac Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2013 License: MIT Imports: 6 Imported by: 2

README

#GAS

GAS (Gopath ASsets) is a lib to load resources (images, text, videos, templates, etc...) using GOPATH.

#Installing

go get github.com/andrebq/gas

#Using

file, err := gas.Open("import/path/to/file.png")
// This is similar to os.Open but it search the GOPATH variable for possible locations
// the first one to match is used
//
// The matched file will be: $GOPATH/src/import/path/to/file.png
//
// Same idea of "GOPATH" variables but for resources and not only go packages.
//
// If the file isn't found on gopath, this will search the current folder for the location.

The behavior is well defined:

First it search the gopath (prepending the src base folder), if the file isn't found then it will search the current folder.

#License

Released under MIT License, see LICENSE for more information

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(file string) (string, error)

Return the absolute filepath for the requested resource or return an error if not found

func Open

func Open(file string) (io.ReadCloser, error)

Open the file for reading or returns an error

For more information, see the FS type

func Refresh

func Refresh()

Refresh the internal FS to reflect possible changes in the UnitedFS

Types

type FS

type FS struct {
	// contains filtered or unexported fields
}

func GopathFS

func GopathFS() *FS

Create a new GopathFS instance

func UnitedFS

func UnitedFS() *FS

Create a FS which is the combination of the GopathFS and the current folder note that the current folder don't require the "src" sub-folder

func (*FS) Abs

func (fs *FS) Abs(file string, allowDir bool) (abs string, err error)

Find the absolute path for the required file.

The returned string is OS depended. If the desired file isn't present in any possible location returns NotFound error.

func (*FS) Open

func (fs *FS) Open(file string) (r io.ReadCloser, err error)

Open the resource for reading

type NotFound

type NotFound string

Used to indicat that the file wasn't found in any possible location

func (NotFound) Error

func (n NotFound) Error() string

Jump to

Keyboard shortcuts

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