Skip to content

Add support writing the header if a slice is empty #69

@cia-rana

Description

@cia-rana

If slice is empty, the header is not output. Are there plans to support outputting it?

Sample code:

func main() {
	users := []struct {
		Name string
		Age  int
	}{}

	var buf bytes.Buffer
	w := csv.NewWriter(&buf)
	csvutil.NewEncoder(w).Encode(users)
	w.Flush()

	fmt.Println(buf.String())
}

Want:

Name,Age

Actual:


Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions