Go struct with methods to handle input. Good idea or Bad idea based on the given situation?

I have the following code below im deciding on either making it just a struct for input or creating a struct with methods to process individual input based on what the api takes. The api can take the following fields...
Query parameter based on which data is sent back. It could be following:

Latitude and Longitude (Decimal degree) e.g: q=48.8567,2.3508
city name e.g.: q=Paris
US zip e.g.: q=10001
UK postcode e.g: q=SW1
Canada postal code e.g: q=G2J
metar:<metar code> e.g: q=metar:EGLL
iata:<3 digit airport code> e.g: q=iata:DXB
auto:ip IP lookup e.g: q=auto:ip
IP address (IPv4 and IPv6 supported) e.g: q=100.0.0.1
Query parameter based on which data is sent back. It could be following:

Latitude and Longitude (Decimal degree) e.g: q=48.8567,2.3508
city name e.g.: q=Paris
US zip e.g.: q=10001
UK postcode e.g: q=SW1
Canada postal code e.g: q=G2J
metar:<metar code> e.g: q=metar:EGLL
iata:<3 digit airport code> e.g: q=iata:DXB
auto:ip IP lookup e.g: q=auto:ip
IP address (IPv4 and IPv6 supported) e.g: q=100.0.0.1
I'm thinking of going with city, UK post, CA post, and US zip. I have the following code below but im not sure which approach is better. Checking the input and processing it with checks for each or creating methods for the struct so it can have the ability to process those inputs individually. Any thoughts? The code is posted below.
package searchinput

import (
"html/template"
"net/http"
"strings"
"log"
)

const WEATHER_API = "https://api.weatherapi.com/v1"

type WeatherInput struct {
City string
Zip int
UKpost string
CApost string
AirportCode string
}


func New() *WeatherInput {
return &WeatherInput{}
}

func (wi *WeatherInput)
package searchinput

import (
"html/template"
"net/http"
"strings"
"log"
)

const WEATHER_API = "https://api.weatherapi.com/v1"

type WeatherInput struct {
City string
Zip int
UKpost string
CApost string
AirportCode string
}


func New() *WeatherInput {
return &WeatherInput{}
}

func (wi *WeatherInput)
1 Reply
MD
MDOP16mo ago
Code is still in works but id rather not get too involved witht the setup if it turns out to be unnecessary
Want results from more Discord servers?
Add your server