This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package util | |
import ( | |
"fmt" | |
"reflect" | |
"strings" | |
) | |
// Use this function to ensure some struct properly inited. Tag `zero_ok` | |
// marks that this field can have zero value. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I was looking for some substitution for X-Macro C preprocessor trick (https://en.wikipedia.org/wiki/X_Macro). | |
// And this method copes with a problem in a lot more straightforward and powerful way. | |
// X-Macro version in C: | |
// | |
// #define SOME_STATES(_) \ | |
// _(SOME_STATE_NEW, "NEW") \ | |
// _(SOME_STATE_IN_PROGRESS, "IN_PROGRESS") \ | |
// _(SOME_STATE_DONE, "DONE") | |
// |