package awsutil
import "github.com/aws/aws-sdk-go-v2/internal/awsutil"
Index ¶
- func Copy(dst, src interface{})
- func CopyOf(src interface{}) (dst interface{})
- func DeepEqual(a, b interface{}) bool
- func Prettify(i interface{}) string
- func StringValue(i interface{}) string
Examples ¶
Functions ¶
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.
Code:play
Output:Example¶
package main
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/internal/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.Prettify(f2))
}
{
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.
Code:play
Output:Example¶
package main
import (
"fmt"
"github.com/aws/aws-sdk-go-v2/internal/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.Prettify(f2))
}
&{
A: 1,
B: [
"hello",
"bye bye"
]
}
func DeepEqual ¶
func DeepEqual(a, b interface{}) bool
DeepEqual returns if the two values are deeply equal like reflect.DeepEqual. In addition to this, this method will also dereference the input values if possible so the DeepEqual performed will not fail if one parameter is a pointer and the other is not.
DeepEqual will not perform indirection of nested values of the input parameters.
func Prettify ¶
func Prettify(i interface{}) string
Prettify returns the string representation of a value.
func StringValue ¶
func StringValue(i interface{}) string
StringValue returns the string representation of a value.
Source Files ¶
copy.go equal.go prettify.go string_value.go
- Version
- v1.36.3 (latest)
- Published
- Feb 27, 2025
- Platform
- linux/amd64
- Imports
- 6 packages
- Last checked
- 1 hour ago –
Tools for package owners.