Json defined in other package

is possible to declare structs like

type respon struct {

Results []test `json:"good"`


type test struct {

Data string `json:"data"`


that will be used to get data from APIs in another file?
right now I have wrote these structs in the same file of the one is doing the http get requests, is possible to write this structs in another file in another package called like package config and than use it inside the package that perform the http get request?

Yes, but you will have to export the types.

1 Like

so I just need to right Capital letter for each type and write instead of a.Respon where a is a variable, I need to do packageName.a.Respon right?

Try it and see.

1 Like