• Stars
    star
    1
  • Language
    Go
  • License
    MIT License
  • Created over 2 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

omg.testingTools

Go Go Report Card Coverage Status Go Reference

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.