gocsv

package
v0.0.0-...-ccfaf30 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package gocsv Excelと相互運用できるCSVを扱うgocsvと関数名の互換性があるパッケージ

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(in interface{}, w io.Writer) error

Marshal returns gocsvを使用して、inをwで与えられたWriterに書き込む

Example
package main

import (
	"os"

	"github.com/topgate/goutils/interop/excel/gocsv"
)

func main() {
	type User struct {
		FirstName string `csv:"first_name"`
		LastName  string `csv:"last_name"`
	}
	users := []User{
		{
			FirstName: "名前",
			LastName:  "名字",
		},
	}
	file, err := os.Create("user.csv")
	if err != nil {
		panic(err)
	}
	if err := gocsv.Marshal(users, file); err != nil {
		panic(err)
	}
}
Output:

func Unmarshal

func Unmarshal(r io.Reader, out interface{}) error

Unmarshal gocsvを使用して、rから読み取られたデータをoutにバインドする

Example
package main

import (
	"os"

	"github.com/topgate/goutils/interop/excel/gocsv"
)

func main() {
	type User struct {
		FirstName string `csv:"first_name"`
		LastName  string `csv:"last_name"`
	}
	users := []User{}
	file, err := os.Open("user.csv")
	if err != nil {
		panic(err)
	}

	if err := gocsv.Unmarshal(file, users); err != nil {
		panic(err)
	}
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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