url

package module
v0.0.0-...-751b2bd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2016 License: BSD-3-Clause Imports: 3 Imported by: 0

README

url

URL related definition and functions for gohtml.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func FullURL

func FullURL(scheme, host string, port int, path string, q QUERY, fragment ...string) URL

func Q

func Q(nameValue ...string) QUERY

Generates a URL QUERY. nameValue's should be paired otherwise the last one is ignored.

Example
fmt.Println(Q("q", "golang", "page", "1"))
Output:

q=golang&page=1

func U

func U(host string, path string, q QUERY, fragment ...string) URL

Makes a URL. port is ignored if set to zero. fragment is optional. If specified as an empty string, a trailing '#' will be appended.

Example
fmt.Println(FullURL("http", "www.example.com", 1234, "/main", Q("q", "\"hello world"), "abc"))
fmt.Println(FullURL("http", "www.example.com", 1234, "main", Q("q&b", "hello+world"), "abc"))
fmt.Println(FullURL("", "www.example.com", 1234, "main", Q("q&b", "hello+world"), "abc"))
fmt.Println(U("", "main", Q("q&b", "hello+world"), "abc"))
fmt.Println(U("", "", Q("q&b", "hello+world"), "abc"))
fmt.Println(U("", "", "", "abc"))
fmt.Println(U("www.example.com", "main", Q("q&b", "hello+world"), "abc"))
fmt.Println(FullURL("http", "www.example.com", 0, "", Q("?", "?"), ""))
fmt.Println(FullURL("http", "www.example.com", 0, "", Q("?", "?")))
Output:

http://www.example.com:1234/main?q=%22hello+world#abc
http://www.example.com:1234/main?q%26b=hello%2Bworld#abc
//www.example.com:1234/main?q%26b=hello%2Bworld#abc
main?q%26b=hello%2Bworld#abc
?q%26b=hello%2Bworld#abc
#abc
//www.example.com/main?q%26b=hello%2Bworld#abc
http://www.example.com/?%3F=%3F#
http://www.example.com/?%3F=%3F

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL