Hello,

 

I saw there was some debates about having “test build tag” here: 
https://github.com/golang/go/issues/21360  and people were asking about real 
life scenario. Here is one with CGO code, initially I was planning to add stubs 
for C land calls into blah_test.go file. (I do not need to test C land calls, I 
just need them to return 0) It turned  out, CGO is not supported in go unit 
tests. I had no other choice but to add these stubs into a normal go file, so 
unit test now is happy. It links locally defined stubs into a test binary. The 
problem now is with a production build where these stubs must be ignored and 
real C land calls from shared library should be invoked.  Having build test tag 
would be really useful, as I could exclude from the production build locally 
defined stubs and life is good.

 

The unit tests are for the library code, I do not know how to tell “go build -a 
./…” when building  the client of the library binary to exclude locally defined 
stubs file.

 

Greatly appreciate some ideas on how to solve it.

 

Thank you

Serguei

 

 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/B8980E65-1B2F-47B6-8C6F-3F9113AEFF28%40gmail.com.

Reply via email to