indent

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

README

indent

Build Status Coverage Status

indent.Reader will prepend each line of underlying input with configured indentation.

example

This shows an example of indent usefulness.

The program:

package main

import (
	"strings"
	"io"
	"os"

	"github.com/wkhere/indent"
)

func main() {
	b := strings.NewReader(example)
	io.Copy(os.Stdout, strings.NewReader("new_root:\n"))
	io.Copy(os.Stdout, indent.NewReader(b, "    "))
}

const example = `
hey: I am yaml
key: val
	nested: something
`

produces the output:

new_root:
    
    hey: I am yaml
    key: val
        nested: something

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader implements prepending each line with indentation.

func NewReader

func NewReader(r io.Reader, indent string) *Reader

NewReader returns a Reader which will prepend each line read from underlying reader with given indentation.

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

Read reads data into p, prepending each line with indentation. When err != nil (including EOF), n is usually > 0.

Directories

Path Synopsis
cmd
indent command

Jump to

Keyboard shortcuts

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