good morning!!!!

Skip to content
Snippets Groups Projects
Commit 23fc7d92 authored by Garet Halliday's avatar Garet Halliday
Browse files

generates

parent d8f13ece
Branches
Tags
No related merge requests found
...@@ -5,6 +5,7 @@ go 1.18 ...@@ -5,6 +5,7 @@ go 1.18
require ( require (
gfx.cafe/util/go/bufpool v0.0.0-20220917152604-80373e5a2c51 gfx.cafe/util/go/bufpool v0.0.0-20220917152604-80373e5a2c51
git.tuxpa.in/a/zlog v1.32.0 git.tuxpa.in/a/zlog v1.32.0
github.com/alecthomas/kong v0.6.1
github.com/davecgh/go-spew v1.1.1 github.com/davecgh/go-spew v1.1.1
github.com/deckarep/golang-set v1.8.0 github.com/deckarep/golang-set v1.8.0
github.com/ethereum/go-ethereum v1.10.22 github.com/ethereum/go-ethereum v1.10.22
...@@ -21,7 +22,6 @@ require ( ...@@ -21,7 +22,6 @@ require (
require ( require (
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/alecthomas/kong v0.6.1 // indirect
github.com/go-ole/go-ole v1.2.1 // indirect github.com/go-ole/go-ole v1.2.1 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.20.0 // indirect github.com/go-openapi/jsonreference v0.20.0 // indirect
......
...@@ -47,6 +47,7 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIO ...@@ -47,6 +47,7 @@ github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIO
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/alecthomas/kong v0.6.1 h1:1kNhcFepkR+HmasQpbiKDLylIL8yh5B5y1zPp5bJimA= github.com/alecthomas/kong v0.6.1 h1:1kNhcFepkR+HmasQpbiKDLylIL8yh5B5y1zPp5bJimA=
github.com/alecthomas/kong v0.6.1/go.mod h1:JfHWDzLmbh/puW6I3V7uWenoh56YNVONW+w8eKeUr9I= github.com/alecthomas/kong v0.6.1/go.mod h1:JfHWDzLmbh/puW6I3V7uWenoh56YNVONW+w8eKeUr9I=
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142 h1:8Uy0oSf5co/NZXje7U1z8Mpep++QJOldL2hs/sBQf48=
github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8= github.com/alecthomas/repr v0.0.0-20210801044451-80ca428c5142/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
......
...@@ -184,9 +184,6 @@ type object struct { ...@@ -184,9 +184,6 @@ type object struct {
func funcMap(openrpc *types.OpenRPCSpec1) template.FuncMap { func funcMap(openrpc *types.OpenRPCSpec1) template.FuncMap {
return template.FuncMap{ return template.FuncMap{
"fixName": func(s string) string {
return "Type" + strings.ReplaceAll(s, " ", "")
},
"programName": getProgramName, "programName": getProgramName,
"derefSchema": derefSchemaRecurse, "derefSchema": derefSchemaRecurse,
"schemaHasRef": schemaHazRef, "schemaHasRef": schemaHazRef,
......
...@@ -495,3 +495,25 @@ func WriteData(w http.ResponseWriter, id interface{}, result interface{}) { ...@@ -495,3 +495,25 @@ func WriteData(w http.ResponseWriter, id interface{}, result interface{}) {
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
w.Write(data) w.Write(data)
} }
nil {
panic(err)
}
w.Header().Set("Content-Type", "application/json")
w.Write(data)
}
func WriteData(w http.ResponseWriter, id interface{}, result interface{}) {
resp := &RPCResultResponse{
JSONRPC: JSONRPC,
ID: id,
Result: StructToResult(result),
}
data, err := json.Marshal(resp)
if err != nil {
WriteError(w, id, ErrInternal.RPCError())
return
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
w.Write(data)
}
This diff is collapsed.
...@@ -24,13 +24,13 @@ type GoOpenRPCService interface { ...@@ -24,13 +24,13 @@ type GoOpenRPCService interface {
} }
{{- range (getObjects .Objects) }} {{- range (getObjects .Objects) }}
{{ printf "type %s struct {" (fixName .Name) }} {{ printf "type %s struct {" .Name }}
{{- range (getFields .Fields) }} {{- range (getFields .Fields) }}
{{ maybeFieldComment .Desc }} {{ maybeFieldComment .Desc }}
{{- if (eq .Name .Type) }} {{- if (eq .Name .Type) }}
{{ printf "%s" (fixName .Name) }} {{ printf "%s" .Name }}
{{- else }} {{- else }}
{{ printf "%s %s `json:\"%s\"`" (fixName .Name) .Type (fixName (lowerFirst .Name)) }} {{ printf "Field%s %s `json:\"%s\"`" .Name .Type (lowerFirst .Name) }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{ printf "}" }} {{ printf "}" }}
......
...@@ -26,7 +26,12 @@ func Inpect(val interface{}) string { ...@@ -26,7 +26,12 @@ func Inpect(val interface{}) string {
} }
func CamelCase(name string) string { func CamelCase(name string) string {
in := strings.Split(name, "_") var in []string
if strings.Contains(name, " ") {
in = strings.Split(name, " ")
} else {
in = strings.Split(name, "_")
}
if len(in) == 0 { if len(in) == 0 {
return strings.Title(name) return strings.Title(name)
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment