goyang

command module
v1.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

Go Coverage Status

Current support for goyang is for the latest 3 Go releases.

goyang

YANG parser and compiler for Go programs.

The yang package (pkg/yang) is used to convert a YANG schema into either an in memory abstract syntax trees (ast) or more fully resolved, in memory, "Entry" trees. An Entry tree consists only of Entry structures and has had augmentation, imports, and includes all applied.

goyang is a sample program that uses the yang (pkg/yang) package.

goyang uses the yang package to create an in-memory tree representation of schemas defined in YANG and then dumps out the contents in several forms. The forms include:

  • tree - a simple tree representation
  • types - list understood types extracted from the schema

The yang package, and the goyang program, are not complete and are a work in progress.

For more complex output types, such as Go structs, and protobuf messages please use the openconfig/ygot package, which uses this package as its backend.

Getting started

To build goyang, ensure you have go language tools installed (available at golang.org) and that the GOPATH environment variable is set to your Go workspace.

  1. go get github.com/openconfig/goyang

    • This will download goyang code and dependencies into the src subdirectory in your workspace.
  2. cd <workspace>/src/github.com/openconfig/goyang

  3. go build

    • This will build the goyang binary and place it in the bin subdirectory in your workspace.
Contributing to goyang

goyang is still a work-in-progress and we welcome contributions. Please see the CONTRIBUTING file for information about how to contribute to the codebase.

Disclaimer

This is not an official Google product.

Documentation

Overview

Program yang parses YANG files, displays errors, and possibly writes something related to the input on output.

Usage: yang [--path DIR] [--format FORMAT] [FORMAT OPTIONS] [MODULE] [FILE ...]

If MODULE is specified (an argument that does not end in .yang), it is taken as the name of the module to display. Any FILEs specified are read, and the tree for MODULE is displayed. If MODULE was not defined in FILEs (or no files were specified), then the file MODULES.yang is read as well. An error is displayed if no definition for MODULE was found.

If MODULE is missing, then all base modules read from the FILEs are displayed. If there are no arguments then standard input is parsed.

If DIR is specified, it is considered a comma separated list of paths to append to the search directory. If DIR appears as DIR/... then DIR and all direct and indirect subdirectories are checked.

FORMAT, which defaults to "tree", specifies the format of output to produce. Use "goyang --help" for a list of available formats.

FORMAT OPTIONS are flags that apply to a specific format. They must follow --format.

THIS PROGRAM IS STILL JUST A DEVELOPMENT TOOL.

Directories

Path Synopsis
pkg
indent
Package indent indents lines of text.
Package indent indents lines of text.
yang
Package yang is used to parse .yang files (see RFC 6020).
Package yang is used to parse .yang files (see RFC 6020).
yangentry
Package yangentry contains high-level helpers for using yang.Entry objects.
Package yangentry contains high-level helpers for using yang.Entry objects.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL