FFFF
Skip to content

Repository files navigation

lesiw.io/fill

Go Reference

A utility for filling Go values.

Example

package main

import (
    "crypto/tls"
    "testing"

    "github.com/google/go-cmp/cmp"
    "github.com/google/go-cmp/cmp/cmpopts"
    "lesiw.io/fill"
)

func TestTlsConfigClone(t *testing.T) {
    opts := cmp.Options{cmpopts.IgnoreUnexported(tls.Config{})}
    for range 100 {
        cfg := new(tls.Config)
        fill.Rand(cfg)
        if want, got := cfg, cfg.Clone(); !cmp.Equal(want, got, opts) {
            t.Fatalf("-original +cloned\n%s", cmp.Diff(want, got, opts))
        }
    }
}

▶️ Run this example on the Go Playground

Releases

Contributors

Languages

0