Fix typo and clean up comments for godoc.
This commit is contained in:
parent
5131b5e390
commit
de12e101e1
4 changed files with 39 additions and 39 deletions
|
@ -495,19 +495,19 @@ func assignField(paramNum int, fieldName string, dest reflect.Value, src reflect
|
||||||
// to be passed unaltered. In particular, the following conversions are
|
// to be passed unaltered. In particular, the following conversions are
|
||||||
// supported:
|
// supported:
|
||||||
//
|
//
|
||||||
// - Conversion between any size signed or unsigned integer so long as the value
|
// - Conversion between any size signed or unsigned integer so long as the
|
||||||
// does not overflow the destination type
|
// value does not overflow the destination type
|
||||||
// - Conversion between float32 and float64 so long as the value does not
|
// - Conversion between float32 and float64 so long as the value does not
|
||||||
// overflow the destination type
|
// overflow the destination type
|
||||||
// - Conversion from string to boolean for everything strconv.ParseBool
|
// - Conversion from string to boolean for everything strconv.ParseBool
|
||||||
// recognizes
|
// recognizes
|
||||||
// - Conversion from string to any size integer for everything strconv.ParseInt
|
// - Conversion from string to any size integer for everything
|
||||||
// and strconv.ParseUint recognizes
|
// strconv.ParseInt and strconv.ParseUint recognizes
|
||||||
// - Conversion from string to any size float for everything strconv.ParseFloat
|
// - Conversion from string to any size float for everything
|
||||||
// recognizes
|
// strconv.ParseFloat recognizes
|
||||||
// - Conversion from string to arrays, slices, structs, and maps by treating
|
// - Conversion from string to arrays, slices, structs, and maps by treating
|
||||||
// the string as marshalled JSON and calling json.Unmarshal into the
|
// the string as marshalled JSON and calling json.Unmarshal into the
|
||||||
// destination field
|
// destination field
|
||||||
func NewCmd(method string, args ...interface{}) (interface{}, error) {
|
func NewCmd(method string, args ...interface{}) (interface{}, error) {
|
||||||
// Look up details about the provided method. Any methods that aren't
|
// Look up details about the provided method. Any methods that aren't
|
||||||
// registered are an error.
|
// registered are an error.
|
||||||
|
|
|
@ -72,7 +72,7 @@ This approach is used since it provides the caller with access to the additional
|
||||||
fields in the request that are not part of the command such as the ID.
|
fields in the request that are not part of the command such as the ID.
|
||||||
|
|
||||||
Unmarshalling a received Response object is also a two step process:
|
Unmarshalling a received Response object is also a two step process:
|
||||||
1) Unmarhsal the raw bytes into a Response struct instance via json.Unmarshal
|
1) Unmarshal the raw bytes into a Response struct instance via json.Unmarshal
|
||||||
2) Depending on the ID, unmarshal the Result field of the unmarshalled
|
2) Depending on the ID, unmarshal the Result field of the unmarshalled
|
||||||
Response to create a concrete type instance
|
Response to create a concrete type instance
|
||||||
|
|
||||||
|
|
|
@ -478,11 +478,11 @@ func isValidResultType(kind reflect.Kind) bool {
|
||||||
// an error will use the key in place of the description.
|
// an error will use the key in place of the description.
|
||||||
//
|
//
|
||||||
// The following outlines the required keys:
|
// The following outlines the required keys:
|
||||||
// - "<method>--synopsis" Synopsis for the command
|
// "<method>--synopsis" Synopsis for the command
|
||||||
// - "<method>-<lowerfieldname>" Description for each command argument
|
// "<method>-<lowerfieldname>" Description for each command argument
|
||||||
// - "<typename>-<lowerfieldname>" Description for each object field
|
// "<typename>-<lowerfieldname>" Description for each object field
|
||||||
// - "<method>--condition<#>" Description for each result condition
|
// "<method>--condition<#>" Description for each result condition
|
||||||
// - "<method>--result<#>" Description for each primitive result num
|
// "<method>--result<#>" Description for each primitive result num
|
||||||
//
|
//
|
||||||
// Notice that the "special" keys synopsis, condition<#>, and result<#> are
|
// Notice that the "special" keys synopsis, condition<#>, and result<#> are
|
||||||
// preceded by a double dash to ensure they don't conflict with field names.
|
// preceded by a double dash to ensure they don't conflict with field names.
|
||||||
|
@ -493,17 +493,17 @@ func isValidResultType(kind reflect.Kind) bool {
|
||||||
//
|
//
|
||||||
// For example, consider the 'help' command itself. There are two possible
|
// For example, consider the 'help' command itself. There are two possible
|
||||||
// returns depending on the provided parameters. So, the help would be
|
// returns depending on the provided parameters. So, the help would be
|
||||||
// generated by calling the function as follows
|
// generated by calling the function as follows:
|
||||||
// GenerateHelp("help", descs, (*string)(nil), (*string)(nil)).
|
// GenerateHelp("help", descs, (*string)(nil), (*string)(nil)).
|
||||||
//
|
//
|
||||||
// The following keys would then be required in the provided descriptions map:
|
// The following keys would then be required in the provided descriptions map:
|
||||||
//
|
//
|
||||||
// - "help--synopsis": "Returns a list of all commands or help for ...."
|
// "help--synopsis": "Returns a list of all commands or help for ...."
|
||||||
// - "help-command": "The command to retrieve help for",
|
// "help-command": "The command to retrieve help for",
|
||||||
// - "help--condition0": "no command provided"
|
// "help--condition0": "no command provided"
|
||||||
// - "help--condition1": "command specified"
|
// "help--condition1": "command specified"
|
||||||
// - "help--result0": "List of commands"
|
// "help--result0": "List of commands"
|
||||||
// - "help--result1": "Help for specified command"
|
// "help--result1": "Help for specified command"
|
||||||
func GenerateHelp(method string, descs map[string]string, resultTypes ...interface{}) (string, error) {
|
func GenerateHelp(method string, descs map[string]string, resultTypes ...interface{}) (string, error) {
|
||||||
// Look up details about the provided method and error out if not
|
// Look up details about the provided method and error out if not
|
||||||
// registered.
|
// registered.
|
||||||
|
|
|
@ -136,19 +136,19 @@ func isAcceptableKind(kind reflect.Kind) bool {
|
||||||
// The type format is very strict since it needs to be able to automatically
|
// The type format is very strict since it needs to be able to automatically
|
||||||
// marshal to and from JSON-RPC 1.0. The following enumerates the requirements:
|
// marshal to and from JSON-RPC 1.0. The following enumerates the requirements:
|
||||||
//
|
//
|
||||||
// - The provided command must be a single pointer to a struct
|
// - The provided command must be a single pointer to a struct
|
||||||
// - All fields must be exported
|
// - All fields must be exported
|
||||||
// - The order of the positional parameters in the marshalled JSON will be in
|
// - The order of the positional parameters in the marshalled JSON will be in
|
||||||
// the same order as declared in the struct definition
|
// the same order as declared in the struct definition
|
||||||
// - Struct embedding is not supported
|
// - Struct embedding is not supported
|
||||||
// - Struct fields may NOT be channels, functions, complex, or interface
|
// - Struct fields may NOT be channels, functions, complex, or interface
|
||||||
// - A field in the provided struct with a pointer is treated as optional
|
// - A field in the provided struct with a pointer is treated as optional
|
||||||
// - Multiple indirections (i.e **int) are not supported
|
// - Multiple indirections (i.e **int) are not supported
|
||||||
// - Once the first optional field (pointer) is encountered, the remaining
|
// - Once the first optional field (pointer) is encountered, the remaining
|
||||||
// fields must also be optional fields (pointers) as required by positional
|
// fields must also be optional fields (pointers) as required by positional
|
||||||
// params
|
// params
|
||||||
// - A field that has a 'jsonrpcdefault' struct tag must be an optional field
|
// - A field that has a 'jsonrpcdefault' struct tag must be an optional field
|
||||||
// (pointer)
|
// (pointer)
|
||||||
//
|
//
|
||||||
// NOTE: This function only needs to be able to examine the structure of the
|
// NOTE: This function only needs to be able to examine the structure of the
|
||||||
// passed struct, so it does not need to be an actual instance. Therefore, it
|
// passed struct, so it does not need to be an actual instance. Therefore, it
|
||||||
|
|
Loading…
Reference in a new issue