Skip to content

Can you embed structs from different packages? #271

@maxless

Description

@maxless

I have structs defined in a different package that are referenced from the main one. In this case msgpack generator ignores them, stating so:

main_test.go: TestRequest: service.RequestHeader: ignored.

Service package:

package service

type RequestHeader struct {
   FieldA int `msg:"fielda"`
}

main package:

type TestRequest struct {
  service.RequestHeader `msg:",flatten"`
  Data struct {
      Test int `msg:"test"`
  } `msg:"data"`
}

If flatten tag is commented out, the message is different:

main_test.go: TestRequest: unresolved identifier: service.RequestHeader

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions