revert changes
This commit is contained in:
parent
cafc5036ef
commit
6b7014a2b7
@ -21,20 +21,6 @@ func (api GoIpcApi) Div(a int, b int) (int, error) {
|
|||||||
return a / b, nil
|
return a / b, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (api GoIpcApi) XorData(data1 []byte, data2 []byte) ([]byte, error) {
|
|
||||||
if len(data1) == 0 || len(data2) == 0 {
|
|
||||||
return nil, fmt.Errorf("empty input data")
|
|
||||||
}
|
|
||||||
if len(data1) != len(data2) {
|
|
||||||
return nil, fmt.Errorf("input data length mismatch")
|
|
||||||
}
|
|
||||||
result := make([]byte, len(data1))
|
|
||||||
for i := 0; i < len(data1); i++ {
|
|
||||||
result[i] = data1[i] ^ data2[i]
|
|
||||||
}
|
|
||||||
return result, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
cwd, err := os.Getwd()
|
cwd, err := os.Getwd()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@ -99,14 +99,8 @@ func (p *GoApiParser) parseFile(sourceFile string) ([]api.Endpoint, error) {
|
|||||||
apiMethod.Name = funcDecl.Name.Name
|
apiMethod.Name = funcDecl.Name.Name
|
||||||
for _, param := range funcDecl.Type.Params.List {
|
for _, param := range funcDecl.Type.Params.List {
|
||||||
var apiPar api.Val
|
var apiPar api.Val
|
||||||
|
ident := param.Type.(*ast.Ident)
|
||||||
if len(param.Names) != 1 {
|
switch ident.Name {
|
||||||
return nil, fmt.Errorf("all parameters in method %s should be named", apiMethod.Name)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch paramType := param.Type.(type) {
|
|
||||||
case *ast.Ident:
|
|
||||||
switch paramType.Name {
|
|
||||||
case "int":
|
case "int":
|
||||||
apiPar.Type = api.TInt
|
apiPar.Type = api.TInt
|
||||||
case "string":
|
case "string":
|
||||||
@ -114,20 +108,11 @@ func (p *GoApiParser) parseFile(sourceFile string) ([]api.Endpoint, error) {
|
|||||||
case "bool":
|
case "bool":
|
||||||
apiPar.Type = api.TBool
|
apiPar.Type = api.TBool
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("parameter type %s is not supported yet", paramType.Name)
|
return nil, fmt.Errorf("parameter type %s is not supported yet", ident.Name)
|
||||||
}
|
}
|
||||||
case *ast.ArrayType:
|
if len(param.Names) != 1 {
|
||||||
switch elementType := paramType.Elt.(type) {
|
return nil, fmt.Errorf("all parameters in method %s should be named", apiMethod.Name)
|
||||||
case *ast.Ident:
|
|
||||||
switch elementType.Name {
|
|
||||||
case "byte":
|
|
||||||
apiPar.Type = api.TBlob
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("parameter type %s is not supported yet", paramType.Name)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apiPar.Name = param.Names[0].Name
|
apiPar.Name = param.Names[0].Name
|
||||||
apiMethod.Params = append(apiMethod.Params, apiPar)
|
apiMethod.Params = append(apiMethod.Params, apiPar)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user