string_tools

package
v1.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 5 Imported by: 10

Documentation

Index

Constants

View Source
const StructMemberString2LineRawTag = "string_line_2_raw"

Variables

This section is empty.

Functions

func String2LineRaw

func String2LineRaw(target string) string

func StringArrRemoveDuplicates

func StringArrRemoveDuplicates(slc []string) []string

func StringInArr

func StringInArr(target string, strArray []string) bool

func StructMemberString2LineRaw added in v1.7.0

func StructMemberString2LineRaw(src interface{}) error

StructMemberString2LineRaw convert struct member string to line raw with tag string_tools.StructMemberString2LineRawTag just support as

type Foo struct {
	Name string `string_line_2_raw:"name"`
	Age  int
}

type Bar struct {
	Foo  Foo
	Name string `string_line_2_raw:"name"`
	Age  int
}

bar := Bar{
		Foo: Foo{
			Name: "Foo\r\n",
			Age:  18,
		},
		Name: "bob\r",
	}
// change to by struct member tag
err := string_tools.StructMemberString2LineRaw(&bar)
if err != nil {
	t.Error(err)
}

// some with struct
newBar := Bar{
	Foo: Foo{
		Name:  `Foo\n`,
		Age:  18,
	},
	Name: `bob\n`,
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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