heredoc

package
v0.0.0-...-6fcca8b Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2016 License: MIT, Apache-2.0 Imports: 3 Imported by: 0

README

#heredoc Build Status Go Walker

##About

Package heredoc provides the here-document with keeping indent.

##Install

$ go get github.com/MakeNowJust/heredoc

##Import

// usual
import "github.com/MakeNowJust/heredoc"
// shortcuts
import . "github.com/MakeNowJust/heredoc/dot"

##Example

package main

import (
	"fmt"
	. "github.com/MakeNowJust/heredoc/dot"
)

func main() {
	fmt.Println(D(`
		Lorem ipsum dolor sit amet, consectetur adipisicing elit,
		sed do eiusmod tempor incididunt ut labore et dolore magna
		aliqua. Ut enim ad minim veniam, ...
	`))
	// Output:
	// Lorem ipsum dolor sit amet, consectetur adipisicing elit,
	// sed do eiusmod tempor incididunt ut labore et dolore magna
	// aliqua. Ut enim ad minim veniam, ...
	//
}

##API Document

##License

This software is released under the MIT License, see LICENSE.

Documentation

Overview

Package heredoc provides the here-document with keeping indent.

Golang supports raw-string syntax.

doc := `
	Foo
	Bar
`

But raw-string cannot recognize indent. Thus such content is indented string, equivalent to

"\n\tFoo\n\tBar\n"

I dont't want this!

However this problem is solved by package heredoc.

doc := heredoc.Doc(`
	Foo
	Bar
`)

It is equivalent to

"Foo\nBar\n"

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Doc

func Doc(raw string) string

heredoc.Doc retutns unindented string as here-document.

Process of making here-document:

  1. Find most little indent size. (Skip empty lines)
  2. Remove this indents of lines.

func Docf

func Docf(raw string, args ...interface{}) string

heredoc.Docf returns unindented and formatted string as here-document. This format is same with package fmt's format.

Types

This section is empty.

Directories

Path Synopsis
Package heredoc_dot is the set of shortcuts for dot import.
Package heredoc_dot is the set of shortcuts for dot import.

Jump to

Keyboard shortcuts

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