However, the python types are not being generated properly, so I get the following error when trying to pass a cycletls.Options to the Request function in python:
type Options struct {
URL string `json:"url"`
Method string `json:"method"`
Headers map[string]string `json:"headers"`
Body string `json:"body"`
Ja3 string `json:"ja3"`
UserAgent string `json:"userAgent"`
Proxy string `json:"proxy"`
Cookies []Cookie `json:"cookies"`
Timeout int `json:"timeout"`
DisableRedirect bool `json:"disableRedirect"`
HeaderOrder []string `json:"headerOrder"`
OrderAsProvided bool `json:"orderAsProvided"`
}
type Response struct {
RequestID string
Status int
Body string
Headers map[string]string
}
And here are the generated python types:
# Python type for cycletls.Options
class cycletls_Options(GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_request.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], GoClass):
self.handle = args[0].handle
_request.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], int):
self.handle = args[0]
_request.IncRef(self.handle)
else:
self.handle = 0
def __del__(self):
_request.DecRef(self.handle)
# Python type for cycletls.Response
class cycletls_Response(GoClass):
""""""
def __init__(self, *args, **kwargs):
"""
handle=A Go-side object is always initialized with an explicit handle=arg
"""
if len(kwargs) == 1 and 'handle' in kwargs:
self.handle = kwargs['handle']
_request.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], GoClass):
self.handle = args[0].handle
_request.IncRef(self.handle)
elif len(args) == 1 and isinstance(args[0], int):
self.handle = args[0]
_request.IncRef(self.handle)
else:
self.handle = 0
def __del__(self):
_request.DecRef(self.handle)
As a workaround, I was able to make it work by redefining the types in my go package, but it is a bit annoying, since I have to redefine the subtypes in cycletls.Options and rebuild the struct inside the function.
I'm trying to build a function which uses imported types as argument and as return type:
However, the python types are not being generated properly, so I get the following error when trying to pass a
cycletls.Options
to theRequest
function in python:Here are the go types:
And here are the generated python types:
As a workaround, I was able to make it work by redefining the types in my go package, but it is a bit annoying, since I have to redefine the subtypes in
cycletls.Options
and rebuild the struct inside the function.