go-csv-tag: github.com/artonge/go-csv-tag Index | Files

package csvtag

import "github.com/artonge/go-csv-tag"

Index

Package Files

csvtag.go dump.go

func Dump Uses

func Dump(slice interface{}, writer io.Writer) error

Dump - writes a slice content into an io.Writer @param slice: an object typically of the form []struct, where the struct using csv tags @param writer: the location of where you will write the slice content to. Example: File, Stdout, etc @return an error if one occures

func DumpToFile Uses

func DumpToFile(slice interface{}, filePath string) error

DumpToFile - writes a slice content into a file specified by filePath @param slice: An object typically of the form []struct, where the struct using csv tag @param filePath: The file path string of where you want the file to be created @return an error if one occures

func Load Uses

func Load(config Config) error

Load - Load a csv file and put it in a array of the dest type This uses tags Example:

tabT := []Test{}
err  := Load(Config{
		Path: "csv_files/valid.csv",
		Dest: &tabT,
		Separator: ';',
		Header: []string{"header1", "header2", "header3"}
	})

The 'separator' and 'header' properties of the config object are optionals @param dest: object where to store the result @return an error if one occurs

type Config Uses

type Config struct {
    Path      string
    Dest      interface{}
    Separator rune
    Header    []string
}

Config struct to pass to the Load function

Package csvtag imports 8 packages (graph) and is imported by 2 packages. Updated 2019-07-22. Refresh now. Tools for package owners.