openconfig / ygot

A YANG-centric Go toolkit - Go/Protobuf Code Generation; Validation; Marshaling/Unmarshaling
Apache License 2.0
286 stars 107 forks source link

imported and not used: "encoding/json", "reflect" #505

Closed lyckety closed 3 years ago

lyckety commented 3 years ago

Good day! When generating go structures for yang models using the command: in the generated package, the unused modules "encoding / json" and "reflect" are included in the import block.

go run ${HOME}/go/src/github.com/openconfig/ygot/generator/generator.go \
    -annotations=false \
    -include_schema=false \
    -output_file=switch.go \
    -package_name=switch \
    ./yang-models/switch.yang

Am I doing something wrong?

robshakir commented 3 years ago

It is recommended to run goimports -w on the files following their generation, which will remove these unused dependencies. Today, ygot doesn't track whether they're needed for a specific generation.

If you'd like to add this behaviour, we'd be happy to review a PR.

r.

On Fri, Mar 12, 2021 at 5:22 AM Well @.***> wrote:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/openconfig/ygot/issues/505, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABE43VPOPV62SPD2EXUUVS3TDIIQ7ANCNFSM4ZCI4ZAQ .

lyckety commented 3 years ago

Thanks!