-
-
Save MilosSimic/1ee36b767b7aa0e432106d9addcf680c to your computer and use it in GitHub Desktop.
Golang snappy encode and decode example
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 main | |
import ( | |
"fmt" | |
"log" | |
"github.com/golang/snappy" | |
) | |
func main() { | |
src := []byte("ABCCCCCCCCCCCCCCCCCCC") | |
var dst []byte | |
encoded := snappy.Encode(dst, src) | |
fmt.Println(string(encoded)) // ABCF | |
decoded, err := snappy.Decode(dst, encoded) | |
if err != nil { | |
log.Fatal(err) | |
} | |
fmt.Println(string(decoded)) // ABCCCCCCCCCCCCCCCCCCC | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment