mirror of
https://github.com/duke-git/lancet.git
synced 2026-03-01 00:35:28 +08:00
doc: add document for EncodeUrl function
This commit is contained in:
@@ -22,6 +22,8 @@ import (
|
|||||||
|
|
||||||
## Index
|
## Index
|
||||||
- [ConvertMapToQueryString](#ConvertMapToQueryString)
|
- [ConvertMapToQueryString](#ConvertMapToQueryString)
|
||||||
|
- [EncodeUrl](#EncodeUrl)
|
||||||
|
|
||||||
- [GetInternalIp](#GetInternalIp)
|
- [GetInternalIp](#GetInternalIp)
|
||||||
- [GetIps](#GetIps)
|
- [GetIps](#GetIps)
|
||||||
- [GetMacAddrs](#GetMacAddrs)
|
- [GetMacAddrs](#GetMacAddrs)
|
||||||
@@ -33,7 +35,6 @@ import (
|
|||||||
- [HttpDelete](#HttpDelete)
|
- [HttpDelete](#HttpDelete)
|
||||||
- [HttpPost](#HttpPost)
|
- [HttpPost](#HttpPost)
|
||||||
- [HttpPut](#HttpPut)
|
- [HttpPut](#HttpPut)
|
||||||
|
|
||||||
- [HttpPatch](#HttpPatch)
|
- [HttpPatch](#HttpPatch)
|
||||||
- [ParseHttpResponse](#ParseHttpResponse)
|
- [ParseHttpResponse](#ParseHttpResponse)
|
||||||
|
|
||||||
@@ -74,6 +75,36 @@ func main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### <span id="EncodeUrl">EncodeUrl</span>
|
||||||
|
<p>Encode url query string values.</p>
|
||||||
|
|
||||||
|
<b>Signature:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
func EncodeUrl(urlStr string) (string, error)
|
||||||
|
```
|
||||||
|
<b>Example:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/duke-git/lancet/v2/netutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
urlAddr := "http://www.lancet.com?a=1&b=[2]"
|
||||||
|
encodedUrl, err := netutil.EncodeUrl(urlAddr)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println(encodedUrl) //http://www.lancet.com?a=1&b=%5B2%5D
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### <span id="GetInternalIp">GetInternalIp</span>
|
### <span id="GetInternalIp">GetInternalIp</span>
|
||||||
<p>Get internal ip information.</p>
|
<p>Get internal ip information.</p>
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
|
|
||||||
## 目录
|
## 目录
|
||||||
- [ConvertMapToQueryString](#ConvertMapToQueryString)
|
- [ConvertMapToQueryString](#ConvertMapToQueryString)
|
||||||
|
- [EncodeUrl](#EncodeUrl)
|
||||||
- [GetInternalIp](#GetInternalIp)
|
- [GetInternalIp](#GetInternalIp)
|
||||||
- [GetIps](#GetIps)
|
- [GetIps](#GetIps)
|
||||||
- [GetMacAddrs](#GetMacAddrs)
|
- [GetMacAddrs](#GetMacAddrs)
|
||||||
@@ -73,6 +74,37 @@ func main() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### <span id="EncodeUrl">EncodeUrl</span>
|
||||||
|
<p>编码url query string的值</p>
|
||||||
|
|
||||||
|
<b>函数签名:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
func EncodeUrl(urlStr string) (string, error)
|
||||||
|
```
|
||||||
|
<b>例子:</b>
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/duke-git/lancet/v2/netutil"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
urlAddr := "http://www.lancet.com?a=1&b=[2]"
|
||||||
|
encodedUrl, err := netutil.EncodeUrl(urlAddr)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
fmt.Println(encodedUrl) //http://www.lancet.com?a=1&b=%5B2%5D
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### <span id="GetInternalIp">GetInternalIp</span>
|
### <span id="GetInternalIp">GetInternalIp</span>
|
||||||
<p>获取内部ip</p>
|
<p>获取内部ip</p>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user