golang tutorial - Url Parsing In Golang - golang - go programming language
Url Parsing In Golang
- A Uniform Resource Locator (URL), normally termed a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifier (URI), although many people use the two terms interchangeably. URLs occur most commonly to reference web pages (http), but are also used for file transfer (ftp), email (mailto), database access (JDBC), and many other applications.
- Most web browsers display the URL of a web page above the page in an address bar. A typical URL could have the form
- which indicates a
- protocol (http),
- a hostname (www.wikitechy.com),
- and a file name (index.html).
- Every HTTP URL conforms to the syntax of a generic URI. A generic URI is of the form: scheme:[//[user[:password]@]host[:port]][/path][?query][#fragment] It comprises:
- The scheme, consisting of a sequence of characters beginning with a letter and followed by any combination of letters, digits, plus (+), period (.), or hyphen (-). Although schemes are case-insensitive, the canonical form is lowercase and documents that specify schemes must with lowercase letters.
- It is followed by a colon (:). Examples of popular schemes include http(s), ftp, mailto, file, data, and irc.
- Two slashes (//): This is required by some schemes and not required by some others.
- An authority part, comprising:
- An optional authentication section of a user name and password, separated by a colon, followed by an at symbol (@)
- A "host", consisting of either a registered name (including but not limited to a hostname), or an IP address. IPv4 addresses must be in dot-decimal notation, and IPv6 addresses must be enclosed in brackets
- An optional port number, separated from the hostname by a colon
- A path, which contains data, usually organized in hierarchical form, that appears as a sequence of segments separated by slashes.
- A web browser will usually dereference a URL by performing an HTTP request to the specified host, by default on port number 80.
- URLs using the https scheme require that requests and responses will be made over a secure connection to the website.
Read AlsoGolang Parser
go parsing details
- Parsing, syntax analysis or syntactic analysis is the process of analysing a string of symbols, either in natural language or in computer languages, conforming to the rules of a formal grammar.
- The term has slightly different meanings in different branches of linguistics and computer science.
- Traditional sentence parsing is often performed as a method of understanding the exact meaning of a sentence or word, sometimes with the aid of devices such as sentence diagrams.
- It usually emphasizes the importance of grammatical divisions such as subject and predicate.
- Within computational linguistics the term is used to refer to the formal analysis by a computer of a sentence or other string of words into its constituents, resulting in a parse tree showing their syntactic relation to each other, which may also contain semantic and other information.
- Within computer science, the term is used in the analysis of computer languages, referring to the syntactic analysis of the input code into its component parts in order to facilitate the writing of compilers and interpreters. The term may also be used to describe a split or separation.
Example : Parsing the Expression 1 + 2 * 3
|Rule1:||E ? E + E||Expression is the sum of two expressions.|
|Rule2:||E ? E * E||Expression is the product of two expressions.|
|Rule3:||E ? number||Expression is a simple number|
|Rule4:||+ has less precedence than *||+ has less precedence than *|