Skip to content

Can't use padding Writer instance twice #13

@kiyonlin

Description

@kiyonlin

I don't know if it is a bug or an intended/designed choose.

package main

import (
	"fmt"
	"io"

	"github.com/muesli/reflow/padding"
)

func main() {
	width := uint(6)
	b := []byte("foo")

	// padding uses spaces per default:
	f := padding.NewWriter(width, nil)

	// but you can also use a custom padding function:
	f = padding.NewWriter(width, func(w io.Writer) {
		w.Write([]byte("."))
	})

	f.Write(b)
	f.Close()
	
	// foo...
	fmt.Println(f.String())

	f.Write(b)
	f.Close()

	// foo...foo
	fmt.Println(f.String())
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions