zipack

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2019 License: MIT Imports: 6 Imported by: 0

README

zipack

GoDoc Go Report Card goreadme

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.


Created by goreadme

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

func NewManager(opts Options) *Manager

NewManager does exactly as it says on the tin.

func (*Manager) GetFileContents

func (mgr *Manager) GetFileContents(path string) ([]byte, error)

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

func (*Manager) GetReader

func (mgr *Manager) GetReader(path string) (io.Reader, error)

GetReader will return an io.Reader for the file, using the cache value first

type Options added in v0.1.0

type Options struct {
	ZipFileName  string
	PreloadPaths []string
}

Options define the configuration for the manager object

Jump to

Keyboard shortcuts

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