github.com/wuhuizuo/gomplate@v3.5.0+incompatible/docs-src/content/functions/net.yml (about)

     1  ns: net
     2  preamble: ''
     3  funcs:
     4    - name: net.LookupIP
     5      description: |
     6        Resolve an IPv4 address for a given host name. When multiple IP addresses
     7        are resolved, the first one is returned.
     8      pipeline: true
     9      arguments:
    10        - name: name
    11          required: true
    12          description: The hostname to look up. This can be a simple hostname, or a fully-qualified domain name.
    13      examples:
    14        - |
    15          $ gomplate -i '{{ net.LookupIP "example.com" }}'
    16          93.184.216.34
    17    - name: net.LookupIPs
    18      description: |
    19        Resolve all IPv4 addresses for a given host name. Returns an array of strings.
    20      pipeline: true
    21      arguments:
    22        - name: name
    23          required: true
    24          description: The hostname to look up. This can be a simple hostname, or a fully-qualified domain name.
    25      examples:
    26        - |
    27          $ gomplate -i '{{ join (net.LookupIPs "twitter.com") "," }}'
    28          104.244.42.65,104.244.42.193
    29    - name: net.LookupCNAME
    30      description: |
    31        Resolve the canonical name for a given host name. This does a DNS lookup for the
    32        `CNAME` record type. If no `CNAME` is present, a canonical form of the given name
    33        is returned -- e.g. `net.LookupCNAME "localhost"` will return `"localhost."`.
    34      pipeline: true
    35      arguments:
    36        - name: name
    37          required: true
    38          description: The hostname to look up. This can be a simple hostname, or a fully-qualified domain name.
    39      examples:
    40        - |
    41          $ gomplate -i '{{ net.LookupCNAME "www.amazon.com" }}'
    42          d3ag4hukkh62yn.cloudfront.net.
    43    - name: net.LookupSRV
    44      description: |
    45        Resolve a DNS [`SRV` service record](https://en.wikipedia.org/wiki/SRV_record).
    46        This implementation supports the canonical [RFC2782](https://tools.ietf.org/html/rfc2782)
    47        form (i.e. `_Service._Proto.Name`), but other forms are also supported, such as
    48        those served by [Consul's DNS interface](https://www.consul.io/docs/agent/dns.html#standard-lookup).
    49  
    50        When multiple records are returned, this function returns the first.
    51  
    52        A [`net.SRV`](https://golang.org/pkg/net/#SRV) data structure is returned. The
    53        following properties are available:
    54        - `Target` - _(string)_ the hostname where the service can be reached
    55        - `Port` - _(uint16)_ the service's port
    56        - `Priority`, `Weight` - see [RFC2782](https://tools.ietf.org/html/rfc2782) for details
    57      pipeline: true
    58      arguments:
    59        - name: name
    60          required: true
    61          description: The service name to look up
    62      examples:
    63        - |
    64          $ gomplate -i '{{ net.LookupSRV "_sip._udp.sip.voice.google.com" | toJSONPretty "  " }}'
    65          {
    66            "Port": 5060,
    67            "Priority": 10,
    68            "Target": "sip-anycast-1.voice.google.com.",
    69            "Weight": 1
    70          }
    71    - name: net.LookupSRVs
    72      description: |
    73        Resolve a DNS [`SRV` service record](https://en.wikipedia.org/wiki/SRV_record).
    74        This implementation supports the canonical [RFC2782](https://tools.ietf.org/html/rfc2782)
    75        form (i.e. `_Service._Proto.Name`), but other forms are also supported, such as
    76        those served by [Consul's DNS interface](https://www.consul.io/docs/agent/dns.html#standard-lookup).
    77  
    78        This function returns all available SRV records.
    79  
    80        An array of [`net.SRV`](https://golang.org/pkg/net/#SRV) data structures is
    81        returned. For each element, the following properties are available:
    82        - `Target` - _(string)_ the hostname where the service can be reached
    83        - `Port` - _(uint16)_ the service's port
    84        - `Priority`, `Weight` - see [RFC2782](https://tools.ietf.org/html/rfc2782) for details
    85      pipeline: true
    86      arguments:
    87        - name: name
    88          required: true
    89          description: The hostname to look up. This can be a simple hostname, or a fully-qualified domain name.
    90      rawExamples:
    91        - |
    92          _input.tmpl:_
    93          ```
    94          {{ range (net.LookupSRVs "_sip._udp.sip.voice.google.com") -}}
    95          priority={{.Priority}}/port={{.Port}}
    96          {{- end }}
    97          ```
    98  
    99          ```console
   100          $ gomplate -f input.tmpl
   101          priority=10/port=5060
   102          priority=20/port=5060
   103          ```
   104    - name: net.LookupTXT
   105      description: |
   106        Resolve a DNS [`TXT` record](https://en.wikipedia.org/wiki/SRV_record).
   107  
   108        This function returns all available TXT records as an array of strings.
   109      pipeline: true
   110      arguments:
   111        - name: name
   112          required: true
   113          description: The host name to look up
   114      examples:
   115        - |
   116          $ gomplate -i '{{net.LookupTXT "example.com" | data.ToJSONPretty "  " }}'
   117          [
   118            "v=spf1 -all"
   119          ]