Documentation ¶
Overview ¶
Package zipack provides a simple object to read files directly from a zip file and cache the results. The code assumes that a folder has been zip'd and thus the files reside within the folder
The struct utilises the sync.Map instead of the built-in map as the cache will only increase and will not be deleting keys. This means that it should be safe for concurrent use.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the container for the zipack logic
func NewManager ¶
NewManager does exactly as it says on the tin.
func (*Manager) GetFileContents ¶
GetFileContents will return the contents of the file, using the cache first
Example ¶
mgr := NewManager(Options{ZipFileName: "./testdata/sqlfiles.zip"}) fileKey := filepath.Join("default", "selectDual.sql") res, err := mgr.GetFileContents(fileKey) if err != nil { panic(fmt.Errorf("Unexpected error: %v", err)) } fmt.Printf("%s", res)
Output: select * from DUAL
Click to show internal directories.
Click to hide internal directories.