Created
November 1, 2025 12:11
-
-
Save vjeantet/52ef24a2c95d30435f48a697618c59fd to your computer and use it in GitHub Desktop.
string to []byte
This file contains hidden or 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 main | |
| import ( | |
| "fmt" | |
| "strings" | |
| ) | |
| func main() { | |
| mystr := "Basic" | |
| var e = fmt.Sprintf("%v", []byte(mystr)) | |
| e = strings.ReplaceAll(e, " ", ",") | |
| e = strings.ReplaceAll(e, "]", "") | |
| e = strings.ReplaceAll(e, "[", "") | |
| fmt.Printf("string([]byte{%s})", e) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment