I am looking to auto-generate some Golang declaration files based on some .json data. Ideally I could put all the declaration/header data into one file. But the way that Golang packages/namespacing works, I doubt I can do that.
Instead of Golang, using TypeScript, I can put a lot of TS types/declarations in one file, using namespaces like so:
export namespace Entities {
export namespace Foo {
export namespace GET {
export namespace Basic {
export interface Req { }
export interface Res { }
}
}
export namespace PUT {
export namespace Basic {
export interface Req { }
export interface Res { }
}
}
}
}
my question is - is there a way to do something like this with golang? Or will I have to use separate files/folders to achieve separate namespaces?
The only thing I know how to do is put them in separate files:
entities/
foo/
get/
put/
post/
delete/
and then in each of those folders, something like:
package get
type Basic struct {
Req struct {}
Res struct {}
}
but that doesn't achieve what I want unfortunately, because I cannot reference the Basic.Req or Basic.Res types directly.