package main
import (
"encoding/csv"
"os"
"strconv"
)
type Demo
struct {
SpuId
int64 `json:"spu_id"`
Title
string `json:"title"`
}
func main() {
var data Demo
f
, err
:= os
.Create("C:\\Users\\Deng\\Desktop\\xx.csv")
if err
!= nil {
panic(err
)
}
defer f
.Close()
_, _ = f
.WriteString("\xEF\xBB\xBF")
writer
:= csv
.NewWriter(f
)
_ = writer
.Write([]string{"spuId", "商品名称"})
_ = writer
.Write([]string{
strconv
.FormatInt(data
.SpuId
, 10) + "\t",
data
.Title
,
})
writer
.Flush()
}
转载请注明原文地址:https://tech.qufami.com/read-9454.html