github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/README.md (about)

     1  # cockroachdb-parser
     2  
     3  [![Go Reference](https://pkg.go.dev/badge/github.com/cockroachdb/cockroachdb-parser.svg)](https://pkg.go.dev/github.com/cockroachdb/cockroachdb-parser)
     4  [![Tests](https://github.com/cockroachdb/cockroachdb-parser/actions/workflows/go.yml/badge.svg)](https://github.com/cockroachdb/cockroachdb-parser/actions/workflows/go.yml)
     5  
     6  `cockroachdb-parser` is a snapshot of the parser package and
     7  all its dependencies from the [CockroachDB repo][repo]. The
     8  smaller package is Apache licensed and contains less dependencies
     9  to pull in when configuring compared to `go get github.com/cockroachdb/cockroach`.
    10  
    11  A README of usage of the parser library can be found [here][parserreadme].
    12  
    13  The SHA this is based off is available in `version`.
    14  
    15  ## Versioning
    16  
    17  Versioning is done by CockroachDB version, with a `v0.` prepended.
    18  For example, `v0.22.1.0.x.y` maps to `v22.1.0` in CockroachDB, where
    19  `.x.y` maps to any subiterations.
    20  
    21  ## Custom patches
    22  
    23  There are custom patches in `patches/` which gets applied to the repo.
    24  This helps us customise the parser slightly for third party users.
    25  
    26  ## Example usage
    27  
    28  ```
    29  import (
    30    ...
    31  	"github.com/cockroachdb/cockroachdb-parser/pkg/sql/parser"
    32    ...
    33  )
    34  
    35  func Parse() error {
    36    ast, err := parser.ParseOne("SELECT 1")
    37    if err != nil {
    38      return err
    39    }
    40    // Do something with the AST
    41    _ = ast
    42  }
    43  ```
    44  
    45  ## Generating a snapshot
    46  
    47  Ensure the [CockroachDB repo][repo] is cloned in your $GOPATH, and then type:
    48  
    49  ```sh
    50  ./snapshot.sh
    51  ```
    52  
    53  [repo]: https://github.com/cockroachdb/cockroach
    54  [parserreadme]: pkg/sql/parser/README.md