2

This is my main file

package datamodels

import "time"

type Training struct {
    Id                 string       `param:"id" json:"id,omitempty" firestore:"id"`
    Image              string       `json:"image,omitempty" firestore:"image" validate:"required"`
    AccountId          string       `json:"accountId,omitempty" firestore:"accountId" validate:"required"`
    Type               string       `json:"type,omitempty" firestore:"type" validate:"required"`
    DogRating          float64      `json:"dogRating,omitempty" firestore:"dogRating" validate:"required"`
    TrainedByRating    float64      `json:"trainedByRating,omitempty" firestore:"trainedByRating" validate:"required"`
    Dog                *TrainingDog `json:"dog,omitempty" firestore:"dog" validate:"required"`
    TrainingTime       int          `json:"trainingTime,omitempty" firestore:"trainingTime" validate:"required"`
    DateTime           *time.Time   `json:"dateTime,omitempty" firestore:"dateTime" validate:"required"`
    Data               *[]Data      `json:"data,omitempty" firestore:"data" validate:"required"`
    UnitsOfMeasurement string       `json:"unitsOfMeasurement,omitempty" firestore:"unitsOfMeasurement" validate:"required"`
    TrainedBy          *DogHandler  `json:"trainedBy,omitempty" firestore:"trainedBy" validate:"required"`
    Team               *TeamInfo    `json:"team,omitempty" firestore:"team" validate:"required"`
    Location           *Location    `json:"location,omitempty" firestore:"location"`
    TimesOfDay         string       `json:"timesOfDay,omitempty" firestore:"timesOfDay"`
    Notes              string       `json:"notes,omitempty" firestore:"notes"`
    CreatedAt          *time.Time   `json:"createdAt,omitempty" firestore:"createdAt,serverTimestamp"`
}

I'm getting undefined: DogHandler (typecheck)go-golangci-lint but and I have that set in the dog model

    type Dog struct {
    Id                string           `param:"id" json:"id,omitempty" firestore:"id"`
    Image             string           `json:"image,omitempty" firestore:"image" validate:"required"`
    AccountId         string           `json:"accountId,omitempty" firestore:"accountId" validate:"required"`
    Teams             []DogTeam        `json:"teams,omitempty" firestore:"teams" validate:"required"`
    Name              string           `json:"name,omitempty" firestore:"name" validate:"required"`
    Breed             *DogBreed        `json:"breed,omitempty" firestore:"breed" validate:"required"`
    Birthday          *time.Time       `json:"birthday,omitempty" firestore:"birthday"`
    Weight            float64          `json:"weight,omitempty" firestore:"weight" validate:"required"`
    Gender            *DogGender       `json:"gender,omitempty" firestore:"gender" validate:"required"`
    DogType           *[]DogType       `json:"type,omitempty" firestore:"type" validate:"required"`
    Status            *DogStatus       `json:"status,omitempty" firestore:"status" validate:"required"`
    Registered        *bool            `json:"registered,omitempty" firestore:"registered" validate:"required"`
    Stats             *DogStats        `json:"stats,omitempty" firestore:"stats" validate:"required"`
    UnitOfMeasurement *MeasurementUnit `json:"unitOfMeasurement,omitempty" firestore:"unitOfMeasurement" validate:"required"`
    CreatedBy         string           `json:"createdBy,omitempty" firestore:"createdBy"`
    Note              string           `json:"note,omitempty" firestore:"note"`
    Handler           *DogHandler      `json:"handler,omitempty" firestore:"handler"`
    ChipId            string           `json:"chipId,omitempty" firestore:"chipId"`
    CreatedAt         *time.Time       `json:"createdAt,omitempty" firestore:"createdAt,serverTimestamp"`
    UpdatedAt         *time.Time       `json:"updatedAt,omitempty" firestore:"updatedAt"`
}

type DogImage struct {
    DogId string `json:"dogId" firestore:"dogId" validate:"required"`
    Url   string `json:"url" firestore:"url" validate:"required"`
}

type DogTeam struct {
    Id   string `json:"id" firestore:"id" validate:"required"`
    Name string `json:"name" firestore:"name" validate:"required"`
}

type DogBreed struct {
    BreedId int    `json:"breedId" firestore:"breedId" validate:"required"`
    Country string `json:"country" firestore:"country" validate:"required"`
    Name    string `json:"name" firestore:"name" validate:"required"`
    Type    string `json:"type" firestore:"type" validate:"required"`
}

type DogHandler struct {
    Name  string   `json:"name" firestore:"name" validate:"required"`
    Id    string   `json:"id" firestore:"id" validate:"required"`
    Utype UserType `json:"type,omitempty" firestore:"type,omitempty"`
}
Almog
  • 2,639
  • 6
  • 30
  • 59
  • 1
    Where are those files located? What is their `package`? How are you importing the packages? How are you executing the code? – mkopriva May 14 '23 at 21:02
  • The files are in a folder models and they all have "package datamodels" – Almog May 15 '23 at 05:29
  • Are you running the linter on a single file or on the whole package? What is the name of the file that declares the `DogHandler` type? (e.g., if the filename ends in `_test.go` then that's likely the problem) Have you tried compiling the code with `go build`, if so what was the output? You need to first identify if this is an issue with your code or if the linter is misbehaving or if you're just incorrectly using the linter. – mkopriva May 15 '23 at 05:51
  • Also, and I don't think this is the issue but who knows, try giving the folder and the package the same name and see if that appeases the linter. – mkopriva May 15 '23 at 05:57
  • 1
    It's a linter, just happing on the file, build has no issues and the file names are just "x_model.go" – Almog May 15 '23 at 05:57

0 Answers0