peopledatalabs / peopledatalabs-go

A Go client for the People Data Labs API
https://docs.peopledatalabs.com/docs/go-sdk
MIT License
7 stars 0 forks source link

Client can't be injected because of private/internal structs #13

Closed Thiht closed 2 years ago

Thiht commented 2 years ago

The pdl.New function returns a private struct, so its type can't be used to perform dependency injection:

type peopleDataLabs struct {
    pdlClient *pdl.pld // pld not exported by package peopledatalabs_go
}

func NewClient(apiKey string) MyInterface {
    return &peopleDataLabs{
        pdlClient: pdl.New(apiKey),
    }
}

The fields of the pdl.pld struct are not usable either because they're declared in internal:

// could not import github.com/peopledatalabs/peopledatalabs-go/internal/api (invalid use of internal package github.com/peopledatalabs/peopledatalabs-go/internal/api)
import pdlapi "github.com/peopledatalabs/peopledatalabs-go/internal/api"

type peopleDataLabs struct {
    pdlPersonClient pdlapi.Person // pld not exported by package peopledatalabs_go
}

func NewClient(apiKey string) MyInterface {
    return &peopleDataLabs{
        pdlClient: pdl.New(apiKey).Person,
    }
}

Can you make the pdl.pld struct public, or declare the internal/api structs public? Thanks

vvillait88 commented 2 years ago

@Thiht Pushing a fix out for this today. Moving the internal folder public in https://github.com/peopledatalabs/peopledatalabs-go/pull/14