Skip to content

Commit

Permalink
chore: rename Json -> JSON for common go naming
Browse files Browse the repository at this point in the history
  • Loading branch information
nilslice committed Feb 2, 2024
1 parent 6432418 commit 19cac8e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions example/countvowels/std_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type CountVowelsOuptut struct {
//export count_vowels_typed
func count_vowels_typed() int32 {
var input CountVowelsInput
if err := pdk.InputJson(&input); err != nil {
if err := pdk.InputJSON(&input); err != nil {
pdk.SetError(err)
return -1
}
Expand All @@ -44,7 +44,7 @@ func count_vowels_typed() int32 {
//export count_vowels_json_output
func count_vowels_json_output() int32 {
output := CountVowelsOuptut{Count: 42, Total: 2.1e7, Vowels: "aAeEiIoOuUyY"}
err := pdk.OutputJson(output)
err := pdk.OutputJSON(output)
if err != nil {
pdk.SetError(err)
return -1
Expand Down
4 changes: 2 additions & 2 deletions example/countvowels/tiny_main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type CountVowelsOuptut struct {
//export count_vowels_typed
func count_vowels_typed() int32 {
var input CountVowelsInput
if err := pdk.InputJson(&input); err != nil {
if err := pdk.InputJSON(&input); err != nil {
pdk.SetError(err)
return -1
}
Expand All @@ -34,7 +34,7 @@ func count_vowels_typed() int32 {
//export count_vowels_json_output
func count_vowels_json_output() int32 {
output := CountVowelsOuptut{Count: 42, Total: 2.1e7, Vowels: "aAeEiIoOuUyY"}
err := pdk.OutputJson(output)
err := pdk.OutputJSON(output)
if err != nil {
pdk.SetError(err)
return -1
Expand Down
6 changes: 3 additions & 3 deletions extism_pdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ func Input() []byte {
return loadInput()
}

func JsonFrom(offset uint64, v any) error {
func JSONFrom(offset uint64, v any) error {
mem := FindMemory(offset)
return json.Unmarshal(mem.ReadBytes(), v)
}

func InputJson(v any) error {
func InputJSON(v any) error {
return json.Unmarshal(Input(), v)
}

func OutputJson(v any) error {
func OutputJSON(v any) error {
b, err := json.Marshal(v)
if err != nil {
return err
Expand Down

0 comments on commit 19cac8e

Please sign in to comment.