gobstore

package module
v0.0.0-...-bdc65d1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2015 License: MPL-2.0 Imports: 3 Imported by: 0

README

gobstore

Example code for storing a gob as a file

import (
  "fmt"
  "github.com/jacec/gobstore/"
  "github.com/jacec/gobstore/datastruct"
)

func main() {

  //creat data struct value
  var dv datastruct.DataValue

  //create example person struct
  var p datastruct.Person
  p.Firstname = "test-firstname"
  p.Lastname = "test-lastname"
  p.Title = "test-title"
  p.Age = 42

  //set the data to the person
  dv.Data = p

  //create a new gobstore
  gs := gobstore.NewGobstore("person")

  //save it!
	gs.Save(dv)

  //now fetch it back
  dt, _ := gs.Fetch()
  fmt.Printf("result: %v", dt)

  //Finally, destroy it from the file system
  gs.Destroy()

}

$ result: {{test-title test-firstname test-lastname 42}}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gobstore

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

Gobstore is a struct containing the details of the gobstore and the lifecycle methods

func NewGobstore

func NewGobstore(GobstoreName string) *Gobstore

NewGobstore returns a new instance of the Gobstore using the supplied name

func (*Gobstore) Destroy

func (gobstore *Gobstore) Destroy() error

Destroy deletes the gobstore from the file system

func (*Gobstore) Fetch

func (gobstore *Gobstore) Fetch() (datastruct.DataValue, error)

Fetch fetches the stored Gobtype and returns it

func (*Gobstore) Save

func (gobstore *Gobstore) Save(value datastruct.DataValue) error

Save saves the supplied value to the gobstore

Directories

Path Synopsis
Package datastruct is where the type being stored is defined Until dynamic loading of go code, you'll need to change this to your type
Package datastruct is where the type being stored is defined Until dynamic loading of go code, you'll need to change this to your type

Jump to

Keyboard shortcuts

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