Skip to content

Instantly share code, notes, and snippets.

@ceving
Created October 29, 2023 08:20
Show Gist options
  • Save ceving/1b5c0fb831751cfd2c3ba26e57782966 to your computer and use it in GitHub Desktop.
Save ceving/1b5c0fb831751cfd2c3ba26e57782966 to your computer and use it in GitHub Desktop.
Calling any function using reflect
package main

import (
	"fmt"
	"reflect"
)

var need_bool = func(b bool) { fmt.Printf("need_bool: %v", b) }

func main() {
	reflect.ValueOf(need_bool).Call([]reflect.Value{reflect.ValueOf(false)})
}

https://goplay.tools/snippet/TY7iqqGGZM3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment