-
-
Save suzuken/f6e8d1c21fa4951f93d5 to your computer and use it in GitHub Desktop.
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 ( | |
"flag" | |
"fmt" | |
"os" | |
"text/template" | |
) | |
func main() { | |
flag.Parse() | |
fmt.Println(flag.Arg(0)) | |
t, err := template.New("").Parse(flag.Arg(0)) | |
if err != nil { | |
fmt.Fprintf(os.Stderr, "build template failed: %s\n", err) | |
os.Exit(1) | |
} | |
if err := t.Execute(os.Stdout, "test"); err != nil { | |
fmt.Fprintf(os.Stderr, "execution failed: %s\n", err) | |
os.Exit(1) | |
} | |
// -> % go run /tmp/t.go 'input: {{printf "%q" .}}' | |
// input: {{printf "%q" .}} | |
// input: "test"% | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment