recordfile

package
v0.0.0-...-95e8d5b Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Example
package main

import (
	"fmt"
	"github.com/name5566/leaf/recordfile"
)

func main() {
	type Record struct {
		// index 0
		IndexInt int "index"
		// index 1
		IndexStr string "index"
		_Number  int32
		Str      string
		Arr1     [2]int
		Arr2     [3][2]int
		Arr3     []int
		St       struct {
			Name string "name"
			Num  int    "num"
		}
		M map[string]int
	}

	rf, err := recordfile.New(Record{})
	if err != nil {
		return
	}

	err = rf.Read("test.txt")
	if err != nil {
		return
	}

	for i := 0; i < rf.NumRecord(); i++ {
		r := rf.Record(i).(*Record)
		fmt.Println(r.IndexInt)
	}

	r := rf.Index(2).(*Record)
	fmt.Println(r.Str)

	r = rf.Indexes(0)[2].(*Record)
	fmt.Println(r.Str)

	r = rf.Indexes(1)["three"].(*Record)
	fmt.Println(r.Str)
	fmt.Println(r.Arr1[1])
	fmt.Println(r.Arr2[2][0])
	fmt.Println(r.Arr3[0])
	fmt.Println(r.St.Name)
	fmt.Println(r.M["key6"])

}
Output:

1
2
3
cat
cat
book
6
4
6
name5566
6

Index

Examples

Constants

This section is empty.

Variables

View Source
var Comma = '\t'
View Source
var Comment = '#'

Functions

This section is empty.

Types

type Index

type Index map[interface{}]interface{}

type RecordFile

type RecordFile struct {
	Comma   rune
	Comment rune
	// contains filtered or unexported fields
}

func New

func New(st interface{}) (*RecordFile, error)

func (*RecordFile) Index

func (rf *RecordFile) Index(i interface{}) interface{}

func (*RecordFile) Indexes

func (rf *RecordFile) Indexes(i int) Index

func (*RecordFile) NumRecord

func (rf *RecordFile) NumRecord() int

func (*RecordFile) Read

func (rf *RecordFile) Read(name string) error

func (*RecordFile) Record

func (rf *RecordFile) Record(i int) interface{}

Jump to

Keyboard shortcuts

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