omg.testingtools
The simple library for change a values of private fields for testing
About omg.testingtools
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.
Frequently Asked Questions
What is omg.testingtools?
omg.testingtools is a Testing library for the Go programming language. The simple library for change a values of private fields for testing
How do I install omg.testingtools?
Install omg.testingtools with the Go module system using `go get dedalqq/omg.testingtools`. Check the repository for the current installation instructions.
What category does omg.testingtools belong to?
omg.testingtools is listed under Testing, specifically Testing Frameworks.