Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/reiver/go-indent

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/reiver/go-indent

  • v1.1.2
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-indent

Package indent provides tools for indentation of UTF-8 text, for the Go programming language.

For example, if you take some text, package indent can make it so it puts tabs, or spaces for indentation in front of each non-empty line.

So, for example, this:

Hello world!

I came; I saw; I conquered.

Can becomes this:

	Hello world!

	I came; I saw; I conquered.

Or:

		Hello world!

		I came; I saw; I conquered.

Or:

-----Hello world!

-----I came; I saw; I conquered.

You can specify how much indentation you want, and what you want the indentation to be (ex: tabs, spaces, or any other symbol, or string).

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-indent

GoDoc

Example

import "github.com/reiver/go-indent"

// ...

var writer io.Writer

// ...

var indentationWriter indent.Writer

indentationWriter.Indentation = "\t\t"
indentationWriter.Writer      = writer

// ...

var s string =
"This is a sentence.\n"+
"This is another sentence.\n"+
"\n"+
"This is a new paragraph.\n"

// ...

io.WriteString(&indentationWriter, s) // <---- Note we write to the ‘indentationWriter’, and not ‘writer’.

// Result will be:
//
// "\t\tThis is a sentence.\n"+
// "\t\tThis is another sentence.\n"+
// "\n"+
// "\t\tThis is a new paragraph.\n"
//
// Note the "\t\t" indentation in front of each non-empty line.
//
// Note the empty line (i.e., "\n") did not get indentation.

FAQs

Package last updated on 11 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc