查找两组数据之间的匹配

I have a function that requests two sets of data. I want to find a match within the two sets of data and update our db with data from the master set of data.

The issue is that the data are interface types. My thought would be to iterate over them and find a match, but I'm not sure if there is a better idea.

How can I iterate over interfaces in Go and match these points of data in the BackfillMissingData function?

This is what I have so far.

type Account struct {
    SalesForceAccountId string
}

func FindIncompleteAccounts(qExec *database.PostgresDB) interface{} {
    var salesForceAccountId string
    rows, err := qExec.Query(
        `query string`)

    if err != nil {
        log.Fatal(err)
    }

    defer rows.Close()
    var accounts []Account

    for rows.Next() {
        err := rows.Scan(&salesForceAccountId)
        if err != nil {
            log.Fatal(err)
        }
        accounts = append(accounts, Account{SalesForceAccountId: salesForceAccountId})
    }

    err = rows.Err()
    if err != nil {
        log.Fatal(err)
    }
    return accounts
}

var client = &http.Client{Timeout: 10 * time.Second}

type Payload struct {
    Companies []Companies `json:"companies"`
}

type Companies struct {
    CompanyId int `json:"companyId"`
    Properties struct {
        SalesForceAccountId struct {
            Value string `json:"value"`
        }
    }
}

func RequestCompanies() interface{} {
    url := fmt.Sprintf("external api", apiKey)

    client := http.Client{
        Timeout: time.Second * 2,
    }

    req, err := http.NewRequest("GET", url, nil)
    if err != nil {
        log.Fatal(err)
    }

    req.Header.Set("User-Agent", "fetching-companies")

    res, getErr := client.Do(req)
    if getErr != nil {
        log.Fatal(getErr)
    }

    body, readErr := ioutil.ReadAll(res.Body)
    if readErr != nil {
        log.Fatal(readErr)
    }

    companies := Payload{}

    jsonErr := json.Unmarshal([]byte(body), &companies)

    if jsonErr != nil {
        log.Fatal(err)
    }

    return companies
}

func BackfillMissingData(qExec *database.PostgresDB) error {
    companies := RequestCompanies()
    incompleteAccounts := FindIncompleteAccounts(qExec)

}

Master Data set

{[{837002081 {{0012a00000IO7ToAAL}}} {837404922 {{001U000000i0xngIAA}}} {840907652 {{0012a00000Icl6gAAB}}}]}

Local Data set

[{0010B00001qY5GoRAS}]

The first number in the master data set is a company id and I want to check against the second item in the master set with my local data.

The problem is that the RequestCompanies() and FindIncompleteAccounts(...) functions return the "empty interface" interface{}, which means that you effectively can't really do anything with those values as they are.

Instead of returning the empty interface, those methods should return either the struct types that they actually represent (e.g. []Account and Payload) or interfaces that abstract the operations on those data that are relevant to your task.

This way you can compare attributes between elements in the two data sets (e.g. a hypothetical Account.ID and Payload.Result.AccountID) and perform your set intersection and eventual update.