csvlogger

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

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

Go to latest
Published: Oct 28, 2022 License: MIT Imports: 7 Imported by: 1

README

csvlogger

struct => csv logger for go.

usage

sample code.
func main() {
	logger, _ := NewLogger("./", "sample")

	type sample struct {
		// export Field.
		Hoge string
		Fuga int
	}

	for i := 0; i < 10; i++ {
		data := sample{
			Hoge: "hoge_" + fmt.Sprint(i),
			Fuga: i,
		}
		logger.Add(&data)
	}
}
result

sample.20210220.csv

Hoge,Fuga
hoge_0,0
hoge_1,1
hoge_2,2
hoge_3,3
hoge_4,4
hoge_5,5
hoge_6,6
hoge_7,7
hoge_8,8
hoge_9,9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Add(data interface{})
}

func NewLogger

func NewLogger(basePath, fileNamme string) (Logger, error)

NewLogger .. Create logger.

Jump to

Keyboard shortcuts

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