Created
August 9, 2020 08:47
-
-
Save brydavis/2f3043ac9440174921a7db410b860019 to your computer and use it in GitHub Desktop.
Generate Data URI from HTML Text
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 ( | |
"encoding/base64" | |
"fmt" | |
) | |
func main() { | |
data := []byte(`<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Doc</title> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<h1>Hello</h1> | |
</body> | |
</html>`) | |
str := base64.StdEncoding.EncodeToString(data) | |
fmt.Println("data:text/html;base64,", str) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment