Skip to content

Commit ac0b6c9

Browse files
committed
add example "main.go" + update example code in README.md
1 parent 3d6aa49 commit ac0b6c9

File tree

2 files changed

+43
-7
lines changed

2 files changed

+43
-7
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ go get -u -v github.com/c0de8/bmfmt
2020
package main
2121

2222
import (
23+
"fmt"
2324
bmfmt "github.com/c0de8/bmfmt"
2425
)
2526

@@ -28,26 +29,28 @@ func main() {
2829
}
2930

3031
func example() {
31-
32+
3233
m := map[string][]string{
3334
"some-key": { "response" },
3435
"Another-Hash-Key": { "first value", "second value" },
3536
}
36-
37+
3738
fmt.Println(m) // fmt the default formatting
3839
/*
39-
map[some-key:[response] Another-Hash-Key:[first value second value]]
40+
map[some-key:[response] Another-Hash-Key:[first value second value]]
4041
*/
4142

42-
bmfmt.Beautify(m) // significant more friendly formatting
43+
err := bmfmt.Beautify(m) // significant more friendly formatting
44+
if err != nil {
45+
fmt.Println("ERROR (bmfmt.Beautify): " + err.Error())
46+
}
4347
/*
44-
[ "some-key" string( 8) ]: "response" string( 8)
45-
[ "Another-Hash-Key" string( 16) ]: "first value", "second value" string( 20)
48+
[ "some-key" string( 8) ]: "response" string( 8)
49+
[ "Another-Hash-Key" string( 16) ]: "first value", "second value" string( 23)
4650
*/
4751

4852
}
4953

50-
5154
```
5255

5356
## License

examples/main.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
bmfmt "github.com/c0de8/bmfmt"
6+
)
7+
8+
func main() {
9+
example()
10+
}
11+
12+
func example() {
13+
14+
m := map[string][]string{
15+
"some-key": {"response"},
16+
"Another-Hash-Key": {"first value", "second value"},
17+
}
18+
19+
fmt.Println(m) // fmt the default formatting
20+
/*
21+
map[some-key:[response] Another-Hash-Key:[first value second value]]
22+
*/
23+
24+
err := bmfmt.Beautify(m) // significant more friendly formatting
25+
if err != nil {
26+
fmt.Println("ERROR (bmfmt.Beautify): " + err.Error())
27+
}
28+
/*
29+
[ "some-key" string( 8) ]: "response" string( 8)
30+
[ "Another-Hash-Key" string( 16) ]: "first value", "second value" string( 23)
31+
*/
32+
33+
}

0 commit comments

Comments
 (0)