Here is an example of encoding and decoding using base64 in different languages:
In TypeScript: Buffer.from('Мегафон').toString('base64') //0JzQtdCz0LDRhNC+0L0=
In Go:
decode, err := base64.URLEncoding.DecodeString("0JzQtdCz0LDRhNC+0L0=") //err : illegal base64 data at input byte 15
If we try to encode the same string in Go:
base64.URLEncoding.EncodeToString([]byte("Мегафон")) //0JzQtdCz0LDRhNC-0L0=
The only difference between the two encodings is the use of + and -.
I attempted a simple solution by replacing + with - using:
v = strings.ReplaceAll(v, "+", "-")
, but this is not ideal.