csvdecoder

package module
v0.0.0-...-3b21cc8 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: MIT Imports: 9 Imported by: 0

README

csv-decoder

GoDoc GitHub license

csv decoder.

Install

$ go get -u github.com/sodefrin/csv-decoder

requirements: go1.13

Usage

package main

import (
	"fmt"
	"log"
	"strings"

	csvdecoder "github.com/sodefrin/csv-decoder"
)

type sample struct {
	Test1 string
	Test2 int
}

func main() {
	out := []*sample{}

	// read "Test1,Test2\na,10\n" from filepath and parse
	if err := csvdecoder.Decode("filepath", &out); err != nil {
		log.Fatal(err)
	}

	for _, v := range out {
		fmt.Printf("%s %d", v.Test1, v.Test2)
		// Output:
		// a 10
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidInterface = errors.New("invalid interface")
	ErrParse            = errors.New("parse error")
)

Functions

func Decode

func Decode(filepath string, out interface{}) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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