repositorypackage
1.0.2
Repository: https://github.com/dedalqq/omg.testingtools.git
Documentation: pkg.go.dev
# Packages
No description provided by the author
# README
omg.testingTools
This tool can be useful for writing a tests. If you want change private field in struct from imported libraries than it can help you.
Example
package main
import (
"strings"
"github.com/dedalqq/omg.testingtools"
)
func TestSomeCase(t *testing.T) {
buffer := strings.Builder{}
testingtools.SetPrivateValue(&buffer, "buf", []byte("data in strings buffer"))
}
How it works
This function finding needs field via reflect
then get pointer from field address via unsafe.Pointer
and write value via variable with the same address as original struct field.