0

I have a package with many functions. I want to test all those functions simultaneously for error handling, because the error handling is common to those functions.

Is there a way to iterate over the imported functions within my test file?

Randomblue
  • 112,777
  • 145
  • 353
  • 547
  • 2
    Do you mean "test functions by reflection" as I did 3 years ago? (http://stackoverflow.com/q/20823836/6309) – VonC Aug 07 '16 at 14:24
  • 2
    Related / possible duplicates: 1. [Call all functions with special prefix or suffix in Golang](http://stackoverflow.com/questions/37384473/call-all-functions-with-special-prefix-or-suffix-in-golang); 2. [Golang: pointer to function from string (function's name)](http://stackoverflow.com/questions/18017979/golang-pointer-to-function-from-string-functions-name) – icza Aug 07 '16 at 14:41
  • @VonC: I want to avoid manually listing the functions `var funcNames = []string{"Func1", "Func2", "Func3"}` – Randomblue Aug 07 '16 at 14:46
  • This says "no": https://groups.google.com/forum/#!topic/golang-nuts/9Di5eHK2eQ0 – Siu Ching Pong -Asuka Kenji- Aug 07 '16 at 15:58

0 Answers0