Comments (1)
Hi, the fields are ordered here:
Line 1032 in 8efc814
Line 1259 in 8efc814
and the writing to the template is done here by looping through the slice:
Line 1325 in 8efc814
If you trace back the dataflow from ParsedDirectory.Fields, then you'll eventually reach goyang's Entry
type with its Dir map[string]*Entry
field, whereupon you'll end up at https://github.com/openconfig/goyang/blob/5ad0d2feb9ce655fb39e414bd4e3696356780cdb/pkg/yang/entry.go#L410-L418, which is invoked in ToEntry
: https://github.com/openconfig/goyang/blob/5ad0d2feb9ce655fb39e414bd4e3696356780cdb/pkg/yang/entry.go#L712-L720, and here you'll finally find some of the original ordering, but even then they're grouped by node type (e.g. leaf vs. leaf-list): https://github.com/openconfig/goyang/blob/5ad0d2feb9ce655fb39e414bd4e3696356780cdb/pkg/yang/ast.go#L454
So fundamentally the issue is that the order of fields are not respected when the Entry
representation is converted from the original parsed AST (i.e. []*Statement).
TLDR: The easiest way I can see is to loop through the set of Entry.Node.Statement().SubStatements() to find the ordering, and use that order at
Line 1032 in 8efc814
Entry
is not available in ParsedDirectory
, so you would need to populate this information into ParsedDirectory
from Line 321 in 8efc814
Entry
from https://github.com/openconfig/ygot/blob/8efc81471e0fe679c453aa0e8c03d752721733bc/ygen/directory.go#L223C4-L223C9
Any other solution would involve adding a new field to either the Entry
AST or other Node types, and that would involve some more effort.
from ygot.
Related Issues (20)
- Generation and path issues HOT 8
- Feature Request: Add an ast.Walk style iterator of GoStructs
- `slices.SortFunc`'s `cmp` function uses wrong return type HOT 2
- Make sure CI runs `go mod tidy` and notices no diffs.
- ygot.diff seems slow
- ytypes.GetNode consumes more CPU & memory than the deprecated util.GetNode
- how to resolve the dependency for gribi HOT 2
- Diff api does generate deletes for leaf list values HOT 6
- Can enum preserve their defined values while converting yang to gostruct using openconfig/ygot\@v0.25.4/generator/generator.go ? HOT 3
- ygot.Diff don't respect presence containers HOT 8
- Mandatory module name in the generated struct names HOT 3
- Doesn't choice and case statement in YANG result in oneof fields in proto? HOT 2
- ygot Validate error, when yang leaf type is union
- When will ygot have support for bits datatype for yang to go conversion HOT 2
- Device Returns Array for Each Interface HOT 3
- Allow ytypes.SetNode on intermediate nodes in compressed mode
- Identity Support in Ygot HOT 1
- Union field has nil value after xml.Unmarshal HOT 5
- [Question] From ygot gostruct or emittedJSON to gNMI Set Update HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ygot.