Closed SeanCondon closed 4 years ago
If there is a dot character . in a YANG identifier then generator will output invalid Go code.
.
generator
For instance in ygot/demo/getting_started/yang/openconfig-interfaces.yang changing leaf out-unicast-pkts to leaf out-unicast-pk.ts at https://github.com/openconfig/ygot/blob/b14560776567988c832f9685af6f0e695ee95727/demo/getting_started/yang/openconfig-interfaces.yang#L639
ygot/demo/getting_started/yang/openconfig-interfaces.yang
out-unicast-pkts
leaf out-unicast-pk.ts
generator will compile fine with (from README)
go run $GOPATH/src/github.com/openconfig/ygot/generator/generator.go -path=yang -output_file=pkg/ocdemo/oc.go -package_name=ocdemo -generate_fakeroot -fakeroot_name=device -compress_paths=true -exclude_modules=ietf-interfaces yang/openconfig-interfaces.yang
but the generated code will contain
OutUnicastPk.ts *uint64 `path:"out-unicast-pk.ts" module:"openconfig-interfaces"`
Something similar happens with container but is more complex.
container
The YANG standard RFC 6020 https://tools.ietf.org/html/rfc6020#section-6.2 says:
Each identifier starts with an uppercase or lowercase ASCII letter or an underscore character, followed by zero or more ASCII letters, digits, underscore characters, hyphens, and dots
The reason for bringing this up is that dot is used in a few places in commonly used YANGS e.g. search for container ieee-802.3ad in https://github.com/Juniper/yang/blob/master/19.3/19.3R1/junos/conf/junos-conf-interfaces%402019-01-01.yang
container ieee-802.3ad
Thanks Sean that's a good point, taking a look.
This is great - thanks so much for addressing it
openconfig/goyang#105 fixes this for both leaves and containers.
If there is a dot character
.
in a YANG identifier thengenerator
will output invalid Go code.For instance in
ygot/demo/getting_started/yang/openconfig-interfaces.yang
changing leafout-unicast-pkts
toleaf out-unicast-pk.ts
at https://github.com/openconfig/ygot/blob/b14560776567988c832f9685af6f0e695ee95727/demo/getting_started/yang/openconfig-interfaces.yang#L639generator will compile fine with (from README)
but the generated code will contain
Something similar happens with
container
but is more complex.The YANG standard RFC 6020 https://tools.ietf.org/html/rfc6020#section-6.2 says:
The reason for bringing this up is that dot is used in a few places in commonly used YANGS e.g. search for
container ieee-802.3ad
in https://github.com/Juniper/yang/blob/master/19.3/19.3R1/junos/conf/junos-conf-interfaces%402019-01-01.yang