Skip to content

Commit

Permalink
[README] Use go build to install from source code (mholt#32)
Browse files Browse the repository at this point in the history
Signed-off-by: Prasad Ghangal <[email protected]>
  • Loading branch information
PrasadG193 authored Nov 8, 2019
1 parent c810d2e commit 7b5b815
Showing 1 changed file with 4 additions and 100 deletions.
104 changes: 4 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,111 +10,15 @@ Converts YAML specs into Go type definitions

### Binary Installation

Pre-compiled binaries are available on the releases page. You can download the correct binary depending on your system arch, put it into $PATH and hit `yaml2go help`
Pre-compiled binaries are available on the releases page. You can download the correct binary depending on your system arch, put it into `$PATH` and hit `yaml2go help`

### Install From Source

#### Step 1: Clone the repo
```bash
$ git clone https://github.com/PrasadG193/yaml2go.git $GOPATH/src/github.com/PrasadG193/yaml2go
```

#### Step 2: Build binary using go install
```bash
$ go install $GOPATH/src/github.com/PrasadG193/yaml2go
```

#### Step 3: Convert YAML specs into Go type
Build binary using go build

```bash
$ cat example1.yaml
kind: test
metadata:
name: cluster
nullfield:
nestedstruct:
- nested:
underscore_field: value
field1:
- 44.5
- 43.6
field2:
- true
- false
nested2:
- nested3:
field1:
- 44
- 43
fieldt:
- true
- false
field3: value
abc:
- def:
- black
- white
array1:
- "string1"
- "string2"
array2:
- 2
- 6
array3:
- 3.14
- 5.12
is_underscore: true
```

```bash
$ GOPATH/bin/yaml2go < example1.yaml
// Yaml2Go
type Yaml2Go struct {
Kind string `yaml:"kind"`
Metadata Metadata `yaml:"metadata"`
Abc []Abc `yaml:"abc"`
Array1 []string `yaml:"array1"`
Array2 []int `yaml:"array2"`
Array3 []float64 `yaml:"array3"`
IsUnderscore bool `yaml:"is_underscore"`
}

// Metadata
type Metadata struct {
Name string `yaml:"name"`
Nullfield interface{} `yaml:"nullfield"`
Nestedstruct []Nestedstruct `yaml:"nestedstruct"`
}

// Nested3
type Nested3 struct {
Field1 []int `yaml:"field1"`
Fieldt []bool `yaml:"fieldt"`
Field3 string `yaml:"field3"`
}

// Abc
type Abc struct {
Def []string `yaml:"def"`
}

// Nestedstruct
type Nestedstruct struct {
Nested Nested `yaml:"nested"`
Nested2 []Nested2 `yaml:"nested2"`
}

// Nested
type Nested struct {
UnderscoreField string `yaml:"underscore_field"`
Field1 []float64 `yaml:"field1"`
Field2 []bool `yaml:"field2"`
}

// Nested2
type Nested2 struct {
Nested3 Nested3 `yaml:"nested3"`
}
$ go get -u github.com/PrasadG193/yaml2go
$ go build -o yaml2go github.com/PrasadG193/yaml2go/cmd/cli
```

## Usage
Expand Down

0 comments on commit 7b5b815

Please sign in to comment.