Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
glassonion1 committed Jun 21, 2024
1 parent 9cca37c commit 8637120
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ XGo contains various useful features for gohers.
- Chunk
- Exponential backoff
- Struct to map
- Obtain pointers to types

## Install
```
Expand Down Expand Up @@ -117,3 +118,32 @@ fmt.Println("contains struct:", containsStruct)
// contains float64: true
// contains struct: true
```

### New
Obtain pointers to types
```go
type Vegetables string

const (
Pea Vegetables = "Pea"
Okra Vegetables = "Okra"
Pumpkin Vegetables = "Pumpkin"
)

type Model struct {
ID *int
Name *string
Material *Vegetables
CreatedAt *time.Time
}

func ExampleNew() {
obj := Model{
ID: xgo.New(123),
Name: xgo.New("R2D2"),
Material: xgo.New(Pea),
CreatedAt: xgo.New(time.Date(2020, 6, 1, 0, 0, 0, 0, time.UTC)),
}
fmt.Println("object:", obj)
}
```
1 change: 0 additions & 1 deletion example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,4 @@ func ExampleNew() {
CreatedAt: xgo.New(time.Date(2020, 6, 1, 0, 0, 0, 0, time.UTC)),
}
fmt.Println("object:", obj)

}

0 comments on commit 8637120

Please sign in to comment.