truncate

package module
v0.0.0-...-902b607 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2019 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

truncate

A Go package that contains just one function that will truncate a given byte slice to a maximum of maxlen visible characters and optionally append a string before closing any open tags (e.g. for an ellipsis). HTML tags are automatically closed generating valid HTML.

Usage

Import the package in your Go program.

import (
    "github.com/andybons/truncate"
)

Call HTML passing in the byte slice, the max len, and the string that should be appended to the truncated HTML before closing the open tags.

func HTML(buf []byte, maxlen int, ellipsis string) ([]byte, error)

License

The MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML

func HTML(buf []byte, maxlen int, suffix string) ([]byte, error)

HTML will truncate a given byte slice to a maximum of maxlen visible characters and optionally append suffix. HTML tags are automatically closed generating valid truncated HTML.

Types

This section is empty.

Jump to

Keyboard shortcuts

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