I have somethind like this in code
var myString = "test string"
I compile it and run
strings myexecutable | grep "test string"
And I see it in output. Is there some way to hide clear text strings in executable in golang? Separate file is not an option.
It's protection not from qualified hackers, but against simple users who can open executable in notepad and find encryption key.
Writing the text as a series of hex bytes won't help you -- the string will still appear as-is in the binary.
One solution is to scramble it, rot-13 maybe, or XOR all the bytes with some value, or even XOR the values with a random number generator that's initialized with a known seed value. At run-time, you will have to regenerate the string you want from the "messed-up" version.
A second issue: that variable probably has an interesting name which appears in the symbol table of the executable, so maybe pick a "dull" name for the encoded string. Maybe even bury the encoded string within a longer string.
As everyone else has noted - someone will find a way to undo your efforts and find the string no matter what you do, but maybe these ideas will help you.
Good luck!