Skip to content

Instantly share code, notes, and snippets.

@brydavis
Created August 9, 2020 08:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brydavis/2f3043ac9440174921a7db410b860019 to your computer and use it in GitHub Desktop.
Save brydavis/2f3043ac9440174921a7db410b860019 to your computer and use it in GitHub Desktop.
Generate Data URI from HTML Text
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