stripmargin

package module
v0.0.0-...-c8c0fd3 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 2 Imported by: 2

README

stripmargin

A tiny Go library that allows you to write multiline strings and strip margin, just like you would in Scala.

Usage

import (
  "fmt"
  "github.com/cstanze/stripmargin"
)

// Use '|' to set the left margin,
// then surround in stripmargin.StripMargin
fmt.Println(stripmargin.StripMargin(`
  |Hello,
  |  world!`))

// Prints:
//
// Hello,
//   world!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StripMargin

func StripMargin(str string) string

Accepts a string and strips margins from a multiline string using `|` similar to Scala's stripMargin method

func StripMarginWith

func StripMarginWith(str string, marginChar rune) string

Accepts a string and a `marginChar` rune to strip margins from a multiline string similar to Scala's stripMargin method

Types

This section is empty.

Jump to

Keyboard shortcuts

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