chore: use gofumpt for code formatting
This commit is contained in:
@@ -26,7 +26,8 @@ const (
|
||||
)
|
||||
|
||||
func New(provider Provider, client *http.Client, token string) ( //nolint:ireturn
|
||||
a API, err error) {
|
||||
a API, err error,
|
||||
) {
|
||||
switch provider {
|
||||
case Cloudflare:
|
||||
return newCloudflare(client), nil
|
||||
@@ -41,9 +42,7 @@ func New(provider Provider, client *http.Client, token string) ( //nolint:iretur
|
||||
}
|
||||
}
|
||||
|
||||
var (
|
||||
ErrProviderNotValid = errors.New("API name is not valid")
|
||||
)
|
||||
var ErrProviderNotValid = errors.New("API name is not valid")
|
||||
|
||||
func ParseProvider(s string) (provider Provider, err error) {
|
||||
switch strings.ToLower(s) {
|
||||
|
||||
@@ -26,7 +26,8 @@ func newCloudflare(client *http.Client) *cloudflare {
|
||||
// and returns an error if the `ip` argument is set since the Cloudflare API
|
||||
// can only be used to provide details about the current machine public IP.
|
||||
func (c *cloudflare) FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||
result models.PublicIP, err error) {
|
||||
result models.PublicIP, err error,
|
||||
) {
|
||||
url := "https://speed.cloudflare.com/meta"
|
||||
if ip.IsValid() {
|
||||
return result, fmt.Errorf("%w: cloudflare cannot provide information on the arbitrary IP address %s",
|
||||
|
||||
@@ -24,7 +24,8 @@ func newIfConfigCo(client *http.Client) *ifConfigCo {
|
||||
// using the ifconfig.co/json API. If the ip is the zero value,
|
||||
// the public IP address of the machine is used as the IP.
|
||||
func (i *ifConfigCo) FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||
result models.PublicIP, err error) {
|
||||
result models.PublicIP, err error,
|
||||
) {
|
||||
url := "https://ifconfig.co/json"
|
||||
if ip.IsValid() {
|
||||
url += "?ip=" + ip.String()
|
||||
|
||||
@@ -27,7 +27,8 @@ func newIP2Location(client *http.Client, token string) *ip2Location {
|
||||
// using the api.ip2location.io API. If the ip is the zero value,
|
||||
// the public IP address of the machine is used as the IP.
|
||||
func (i *ip2Location) FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||
result models.PublicIP, err error) {
|
||||
result models.PublicIP, err error,
|
||||
) {
|
||||
url := "https://api.ip2location.io/"
|
||||
if ip.IsValid() {
|
||||
url += "?ip=" + ip.String()
|
||||
|
||||
@@ -28,7 +28,8 @@ func newIPInfo(client *http.Client, token string) *ipInfo {
|
||||
// using the ipinfo.io API. If the ip is the zero value, the public IP address
|
||||
// of the machine is used as the IP.
|
||||
func (i *ipInfo) FetchInfo(ctx context.Context, ip netip.Addr) (
|
||||
result models.PublicIP, err error) {
|
||||
result models.PublicIP, err error,
|
||||
) {
|
||||
url := "https://ipinfo.io/"
|
||||
switch {
|
||||
case ip.Is6():
|
||||
|
||||
@@ -14,7 +14,8 @@ import (
|
||||
// an error is returned, so the results returned should be considered
|
||||
// incomplete in this case.
|
||||
func FetchMultiInfo(ctx context.Context, fetcher Fetcher, ips []netip.Addr) (
|
||||
results []models.PublicIP, err error) {
|
||||
results []models.PublicIP, err error,
|
||||
) {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
type asyncResult struct {
|
||||
|
||||
Reference in New Issue
Block a user