unexport impl structs

This commit is contained in:
Pascal Fischer
2024-11-22 19:57:58 +01:00
parent dcbadd47c0
commit f2280edecd
3 changed files with 11 additions and 11 deletions

View File

@@ -21,7 +21,7 @@ type Geolocation interface {
Stop() error Stop() error
} }
type GeolocationImpl struct { type geolocationImpl struct {
mmdbPath string mmdbPath string
mux sync.RWMutex mux sync.RWMutex
db *maxminddb.Reader db *maxminddb.Reader
@@ -93,7 +93,7 @@ func NewGeolocation(ctx context.Context, dataDir string, autoUpdate bool) (Geolo
return nil, err return nil, err
} }
geo := &GeolocationImpl{ geo := &geolocationImpl{
mmdbPath: mmdbPath, mmdbPath: mmdbPath,
mux: sync.RWMutex{}, mux: sync.RWMutex{},
db: db, db: db,
@@ -120,7 +120,7 @@ func openDB(mmdbPath string) (*maxminddb.Reader, error) {
return db, nil return db, nil
} }
func (gl *GeolocationImpl) Lookup(ip net.IP) (*Record, error) { func (gl *geolocationImpl) Lookup(ip net.IP) (*Record, error) {
gl.mux.RLock() gl.mux.RLock()
defer gl.mux.RUnlock() defer gl.mux.RUnlock()
@@ -134,7 +134,7 @@ func (gl *GeolocationImpl) Lookup(ip net.IP) (*Record, error) {
} }
// GetAllCountries retrieves a list of all countries. // GetAllCountries retrieves a list of all countries.
func (gl *GeolocationImpl) GetAllCountries() ([]Country, error) { func (gl *geolocationImpl) GetAllCountries() ([]Country, error) {
allCountries, err := gl.locationDB.GetAllCountries() allCountries, err := gl.locationDB.GetAllCountries()
if err != nil { if err != nil {
return nil, err return nil, err
@@ -150,7 +150,7 @@ func (gl *GeolocationImpl) GetAllCountries() ([]Country, error) {
} }
// GetCitiesByCountry retrieves a list of cities in a specific country based on the country's ISO code. // GetCitiesByCountry retrieves a list of cities in a specific country based on the country's ISO code.
func (gl *GeolocationImpl) GetCitiesByCountry(countryISOCode string) ([]City, error) { func (gl *geolocationImpl) GetCitiesByCountry(countryISOCode string) ([]City, error) {
allCities, err := gl.locationDB.GetCitiesByCountry(countryISOCode) allCities, err := gl.locationDB.GetCitiesByCountry(countryISOCode)
if err != nil { if err != nil {
return nil, err return nil, err
@@ -165,7 +165,7 @@ func (gl *GeolocationImpl) GetCitiesByCountry(countryISOCode string) ([]City, er
return cities, nil return cities, nil
} }
func (gl *GeolocationImpl) Stop() error { func (gl *geolocationImpl) Stop() error {
close(gl.stopCh) close(gl.stopCh)
if gl.db != nil { if gl.db != nil {
if err := gl.db.Close(); err != nil { if err := gl.db.Close(); err != nil {

View File

@@ -24,7 +24,7 @@ func TestGeoLite_Lookup(t *testing.T) {
db, err := openDB(filename) db, err := openDB(filename)
assert.NoError(t, err) assert.NoError(t, err)
geo := &GeolocationImpl{ geo := &geolocationImpl{
mux: sync.RWMutex{}, mux: sync.RWMutex{},
db: db, db: db,
stopCh: make(chan struct{}), stopCh: make(chan struct{}),

View File

@@ -76,8 +76,8 @@ type JWTValidator interface {
ValidateAndParse(ctx context.Context, token string) (*jwt.Token, error) ValidateAndParse(ctx context.Context, token string) (*jwt.Token, error)
} }
// JWTValidatorImpl struct to handle token validation and parsing // jwtValidatorImpl struct to handle token validation and parsing
type JWTValidatorImpl struct { type jwtValidatorImpl struct {
options Options options Options
} }
@@ -142,13 +142,13 @@ func NewJWTValidator(ctx context.Context, issuer string, audienceList []string,
options.UserProperty = "user" options.UserProperty = "user"
} }
return &JWTValidatorImpl{ return &jwtValidatorImpl{
options: options, options: options,
}, nil }, nil
} }
// ValidateAndParse validates the token and returns the parsed token // ValidateAndParse validates the token and returns the parsed token
func (m *JWTValidatorImpl) ValidateAndParse(ctx context.Context, token string) (*jwt.Token, error) { func (m *jwtValidatorImpl) ValidateAndParse(ctx context.Context, token string) (*jwt.Token, error) {
// If the token is empty... // If the token is empty...
if token == "" { if token == "" {
// Check if it was required // Check if it was required