forked from brettlangdon/forge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added file system interface to process config files from any file system
- Loading branch information
Showing
14 changed files
with
60 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ package main | |
import ( | ||
"fmt" | ||
|
||
"aahframework.org/forge.v0" | ||
"github.com/go-aah/forge" | ||
) | ||
|
||
func main() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ import ( | |
"bytes" | ||
"fmt" | ||
|
||
"aahframework.org/forge.v0" | ||
"github.com/go-aah/forge" | ||
) | ||
|
||
func Example() { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package forge | ||
|
||
import ( | ||
"io" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
var fs FileSystem = new(NativeFS) | ||
|
||
// FileSystem interface to expand configuration file parsing possiblities. | ||
type FileSystem interface { | ||
Open(filename string) (io.Reader, error) | ||
Glob(pattern string) ([]string, error) | ||
} | ||
|
||
// RegisterFS method to register new file system into forge. | ||
func RegisterFS(fileSystem FileSystem) { | ||
fs = fileSystem | ||
} | ||
|
||
// NativeFS type defines methods for native file system. | ||
type NativeFS uint8 | ||
|
||
func (NativeFS) Open(filename string) (io.Reader, error) { | ||
return os.Open(filename) | ||
} | ||
|
||
func (NativeFS) Glob(pattern string) ([]string, error) { | ||
return filepath.Glob(pattern) | ||
} | ||
|
||
// Close method closes the give file if its compliant to `io.Closer` | ||
func close(f interface{}) error { | ||
if c, ok := f.(io.Closer); ok { | ||
return c.Close() | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module github.com/go-aah/forge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters