Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Shebang2Slashes ¶
func Shebang2Slashes(p []byte)
Shebang2Slashes replaces first two bytes of given p with two slashes if they are Shebang chars.
func ShebangReadFile ¶
ShebangReadFile reads given path and returns the content of the file. If file starts with Shebang #! , it is replaced with //. This function can be used as ReadFile callback in FileImporter.
Types ¶
type FileImporter ¶
type FileImporter struct { WorkDir string FileReader func(string) ([]byte, error) // contains filtered or unexported fields }
FileImporter is an implemention of charlang.ExtImporter to import files from file system. It uses absolute paths of module as import names.
func (*FileImporter) Fork ¶
func (m *FileImporter) Fork(moduleName string) charlang.ExtImporter
Fork returns a new instance of FileImporter as charlang.ExtImporter by capturing the working directory of the module. moduleName should be the same value provided by Name call.
func (*FileImporter) Get ¶
func (m *FileImporter) Get(name string) charlang.ExtImporter
Get impelements charlang.ExtImporter and returns itself if name is not empty.
func (*FileImporter) Import ¶
func (m *FileImporter) Import(moduleName string) (interface{}, error)
Import returns the content of the path determined by Name call. Empty name will return an error.
func (*FileImporter) Name ¶
func (m *FileImporter) Name() string
Name returns the absoule path of the module. A previous Get call is required to get the name of the imported module.