urlencode

A command line utility to urlencode strings
Log | Files | Refs | README | LICENSE

main.go (293B)


      1 package main
      2 
      3 import (
      4 	"fmt"
      5 	"io/ioutil"
      6 	"net/url"
      7 	"os"
      8 )
      9 
     10 func main() {
     11 	bytes, err := ioutil.ReadAll(os.Stdin)
     12 	// Quick n dirty
     13 	if err != nil {
     14 		panic(err)
     15 	}
     16 	// Get rid of that %0A at the end
     17 	bytes = bytes[:len(bytes)-1]
     18 
     19 	out := url.PathEscape(string(bytes))
     20 
     21 	fmt.Println(out)
     22 }