buf: github.com/bufbuild/buf/internal/pkg/stringutil Index | Files

package stringutil

import "github.com/bufbuild/buf/internal/pkg/stringutil"

Package stringutil implements string utilities.


Package Files


func MapToSortedSlice Uses

func MapToSortedSlice(m map[string]struct{}) []string

MapToSortedSlice transforms m to a sorted slice.

func SliceToChunks Uses

func SliceToChunks(s []string, chunkSize int) [][]string

SliceToChunks splits s into chunks of the given chunk size.

If s is nil or empty, returns empty. If chunkSize is <=0, returns [][]string{s}.

func SliceToMap Uses

func SliceToMap(s []string) map[string]struct{}

SliceToMap transforms s to a map.

func SliceToUniqueSortedSlice Uses

func SliceToUniqueSortedSlice(s []string) []string

SliceToUniqueSortedSlice returns a sorted copy of s with no duplicates.

func SliceToUniqueSortedSliceFilterEmptyStrings Uses

func SliceToUniqueSortedSliceFilterEmptyStrings(s []string) []string

SliceToUniqueSortedSliceFilterEmptyStrings returns a sorted copy of s with no duplicates and no empty strings.

Strings with only spaces are considered empty.

func ToLowerSnakeCase Uses

func ToLowerSnakeCase(s string, options ...SnakeCaseOption) string

ToLowerSnakeCase transforms s to lower_snake_case.

func ToPascalCase Uses

func ToPascalCase(s string) string

ToPascalCase converts s to PascalCase.

Splits on '-', '_', ' ', '\t', '\n', '\r'. Uppercase letters will stay uppercase,

func ToUpperSnakeCase Uses

func ToUpperSnakeCase(s string, options ...SnakeCaseOption) string

ToUpperSnakeCase transforms s to UPPER_SNAKE_CASE.

func TrimLines Uses

func TrimLines(output string) string

TrimLines splits the output into individual lines and trims the spaces from each line.

This also trims the start and end spaces from the original output.

type SnakeCaseOption Uses

type SnakeCaseOption func(*snakeCaseOptions)

SnakeCaseOption is an option for snake_case conversions.

func SnakeCaseWithNewWordOnDigits Uses

func SnakeCaseWithNewWordOnDigits() SnakeCaseOption

SnakeCaseWithNewWordOnDigits is a SnakeCaseOption that signfies to split on digits, ie foo_bar_1 instead of foo_bar1.

Package stringutil imports 3 packages (graph). Updated 2019-11-16. Refresh now. Tools for package owners.