awsutil

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 12 Imported by: 28

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize added in v1.0.21

func Capitalize(s string) string

Capitalize capitalizes the first character of the string.

func Copy

func Copy(dst, src interface{})

Copy deeply copies a src structure to dst. Useful for copying request and response structures.

Can copy between structs of different type, but will only copy fields which are assignable, and exist in both structs. Fields which are not assignable, or do not exist in both structs are ignored.

Example
package main

import (
	"fmt"

	"github.com/ks3sdklib/aws-sdk-go/aws/awsutil"
)

func main() {
	type Foo struct {
		A int
		B []*string
	}

	// Create the initial value
	str1 := "hello"
	str2 := "bye bye"
	f1 := &Foo{A: 1, B: []*string{&str1, &str2}}

	// Do the copy
	var f2 Foo
	awsutil.Copy(&f2, f1)

	// Print the result
	fmt.Println(awsutil.StringValue(f2))

}
Output:

{
  A: 1,
  B: ["hello","bye bye"]
}

func CopyOf

func CopyOf(src interface{}) (dst interface{})

CopyOf returns a copy of src while also allocating the memory for dst. src must be a pointer type or this operation will fail.

Example
package main

import (
	"fmt"

	"github.com/ks3sdklib/aws-sdk-go/aws/awsutil"
)

func main() {
	type Foo struct {
		A int
		B []*string
	}

	// Create the initial value
	str1 := "hello"
	str2 := "bye bye"
	f1 := &Foo{A: 1, B: []*string{&str1, &str2}}

	// Do the copy
	v := awsutil.CopyOf(f1)
	var f2 *Foo = v.(*Foo)

	// Print the result
	fmt.Println(awsutil.StringValue(f2))

}
Output:

{
  A: 1,
  B: ["hello","bye bye"]
}

func GoFmt added in v1.0.21

func GoFmt(buf string) string

GoFmt returns the Go formated string of the input.

Panics if the format fails.

func PrettyPrint added in v1.0.21

func PrettyPrint(v interface{}) string

PrettyPrint generates a human readable representation of the value v. All values of v are recursively found and pretty printed also.

func SetValueAtAnyPath

func SetValueAtAnyPath(i interface{}, path string, v interface{})

SetValueAtAnyPath sets an object at the case insensitive lexical path inside of a structure

func SetValueAtPath

func SetValueAtPath(i interface{}, path string, v interface{})

SetValueAtPath sets an object at the lexical path inside of a structure

func SortXML added in v1.0.21

func SortXML(r io.Reader) string

SortXML sorts the reader's XML elements

func StringValue

func StringValue(i interface{}) string

StringValue returns the string representation of a value.

func Trim added in v1.0.21

func Trim(s string) string

Trim removes all leading and trailing white space.

All consecutive spaces will be reduced to a single space.

func ValuesAtAnyPath

func ValuesAtAnyPath(i interface{}, path string) []interface{}

ValuesAtAnyPath returns a list of objects at the case-insensitive lexical path inside of a structure

func ValuesAtPath

func ValuesAtPath(i interface{}, path string) []interface{}

ValuesAtPath returns a list of objects at the lexical path inside of a structure

func WalkDir added in v1.0.21

func WalkDir(dirPth, suffix string) (files []string, err error)

获取指定目录及所有子目录下的所有文件,可以匹配后缀过滤。

Types

This section is empty.

Jump to

Keyboard shortcuts

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