-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace JSON struct wrappers with struct tags
move (My)SQL initialization stuff to sql script to be run every time
- Loading branch information
Showing
16 changed files
with
437 additions
and
693 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
type Color struct { | ||
Red int `json:"red"` | ||
Green int `json:"green"` | ||
Blue int `json:"blue"` | ||
} | ||
|
||
func TestAPI(t *testing.T) { | ||
var api string | ||
var err error | ||
|
||
if api, err = marshalAPI("colorsSlice", []Color{ | ||
Color{255, 0, 0}, | ||
Color{0, 255, 0}, | ||
Color{0, 0, 255}, | ||
}, true); err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
fmt.Println("API slice: " + api) | ||
|
||
if api, err = marshalAPI("colorsMap", map[string]Color{ | ||
"red": Color{255, 0, 0}, | ||
"green": Color{0, 255, 0}, | ||
"blue": Color{0, 0, 255}, | ||
}, true); err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
fmt.Println("API map: " + api) | ||
|
||
if api, err = marshalAPI("color", Color{255, 0, 0}, true); err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
fmt.Println("API struct: " + api) | ||
|
||
if api, err = marshalAPI("error", "Some error", false); err != nil { | ||
t.Fatal(err.Error()) | ||
} | ||
fmt.Println("API string: " + api) | ||
} |
Oops, something went wrong.