Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleaning #3713

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions examples/templates/base/README.md.tmpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# [{NAME}]

Test case for [{NAME}].

Run

```
go build -o out main.go
./out
```

If you remove this example, you will need to also remove the reference to it from ./go.work in the root folder.
24 changes: 15 additions & 9 deletions examples/templates/base/main.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
package main

import (
"encoding/json"
"fmt"

"github.com/TrueBlocks/trueblocks-core/sdk"
)

func main() {
opts := sdk.BlocksOptions{
BlockIds: []string{"latest"},
BlockIds: []string{
"1000", // Query block 1,000
"2020-12-31T12:59:59", // Query block at 12:59:59 on 2020-12-31
},
}

blocks, _, err := opts.Blocks()
// Returns an array of blocks or error
blocks, _, err := opts.BlocksHashes()
if err != nil {
fmt.Println(err)
return
}

fmt.Println("[")
for i, block := range blocks {
if i > 0 {
fmt.Println(",")
}
fmt.Println(block.String())
// Show the data as a CSV
fmt.Println("blockNumber,timestamp,date,transactionCount")
for _, block := range blocks {
fmt.Printf("%d,%d,%s,%d\n", block.BlockNumber, block.Timestamp, block.Date(), len(block.Transactions))
}
fmt.Println("]")

// Show the data as JSON
bytes, _ := json.MarshalIndent(blocks, "", " ")
fmt.Println(string(bytes))
}
2 changes: 0 additions & 2 deletions src/dev_tools/goMaker/types/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,5 @@ func (cb *CodeBase) Generate(generators []Generator) {
}
}
}

logger.Info()
logger.Info(colors.Green + "Done..." + strings.Repeat(" ", 120) + colors.Off + "\033[K")
}
Loading