Skip to content

Commit

Permalink
Rename util package to yangentry package. (openconfig#220)
Browse files Browse the repository at this point in the history
* Rename `util` package to `yangentry` package.

Per https://go.dev/blog/package-names we should try to avoid using a
generic package name.

Since `Entry` is the primary output users are interested in I thought
this is not too bad of a name.

Fixes openconfig#213
  • Loading branch information
wenovus authored Feb 22, 2022
1 parent fa1e168 commit de640d0
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 9 deletions.
9 changes: 4 additions & 5 deletions pkg/util/build_yang.go → pkg/yangentry/build_yang.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Package util contains goyang utility functions that could be useful for
// external users.
package util
// Package yangentry contains high-level helpers for using yang.Entry objects.
package yangentry

import (
"fmt"

"github.com/openconfig/goyang/pkg/yang"
)

// ProcessModules takes a list of either module/submodule names or .yang file
// Parse takes a list of either module/submodule names or .yang file
// paths, and a list of include paths. It runs the yang parser on the YANG
// files by searching for them in the include paths or in the current
// directory, returning a slice of yang.Entry pointers which represent the
// parsed top level modules. It also returns a list of errors encountered while
// parsing, if any.
func ProcessModules(yangfiles, path []string) (map[string]*yang.Entry, []error) {
func Parse(yangfiles, path []string) (map[string]*yang.Entry, []error) {
ms := yang.NewModules()

for _, p := range path {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package util
package yangentry

import "testing"

// TestProcessModules tests the ProcessModules function - which takes an input
// TestParse tests the Parse function - which takes an input
// set of modules and processes them using the goyang compiler into a set of
// yang.Entry pointers.
func TestProcessModules(t *testing.T) {
func TestParse(t *testing.T) {
tests := []struct {
name string
inFiles []string
Expand Down Expand Up @@ -59,7 +59,7 @@ func TestProcessModules(t *testing.T) {
}}

for _, tt := range tests {
entries, errs := ProcessModules(tt.inFiles, tt.inPath)
entries, errs := Parse(tt.inFiles, tt.inPath)
if len(errs) != 0 && !tt.wantErr {
t.Errorf("%s: unexpected error processing modules: %v", tt.name, errs)
continue
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit de640d0

Please sign in to comment.