install by go get.
go get github.com/lemonnekogh/godence
If you have the following Cadence struct.
pub struct Person {
pub var age: UInt8
pub var Name: String
}
import "github.com/LemonNekoGH/godence"
type Person struct {
Age uint8 `godence:"age"` // you can specify field name in cadence by tag.
Name string
}
func main() {
dist := &Person{}
// Omit: You got a Cadence value from a script or transaction. And return value named 'ret'.
godence.ToGo(ret, dist)
}
Convert to Cadecne Struct, Event, Resource is currently not support becase type name of Struct, Event, Resource is unpredictable.
Can i convert to AnyStruct and AnyResource?
- Flow CLI: Use to emulate flow network.
- Start the flow emulator with command:
flow emulator
- Deploy contract for testing to the emulator network:
flow deploy
- Open another terminal and run
go clean -testcache && go test .
- Documents for Go to Cadence
- Go
int
to CadenceInt
- Go
int8
to CadenceInt8
- Go
int16
to CadenceInt16
- Go
int32
to CadenceInt32
- Go
int64
to CadenceInt64
- Go
*big.Int
to CadenceInt128
- Go
*big.Int
to CadenceInt256
- Go
uint
to CadenceUInt
- Go
uint8
to CadenceUInt8
- Go
uint16
to CadenceUInt16
- Go
uint32
to CadenceUInt32
- Go
uint64
to CadenceUInt64
- Go
*big.Int
to CadenceUInt128
- Go
*big.Int
to CadenceUInt256
- Go
int64
to CadenceFix64
- Go
uint64
to CadenceUFix64
- Go
string
to CadenceString
- Go
string
to CadencePath
- Go
string
to CadenceAddress
- Go
bool
to CadenceBool
- Go
slice
orarray
to CadenceArray
-
Go?
to CadenceStruct
- Go
string
to CadenceCharacter
-
Go?
to CadenceResource
- Go
?
to CadenceDictionary
-
Go?
to CadenceEvent
- Documents for Cadence base type to Go.
- Documents for Cadence complex type to Go.
- Cadence
Int
to Go*big.Int
- Cadence
Int8
to Goint8
- Cadence
Int16
to Goint16
- Cadence
Int32
to Goint32
- Cadence
Int64
to Goint64
- Cadence
Int128
to Go*big.Int
- Cadence
Int256
to Go*big.Int
- Cadence
UInt
to Go*big.Int
- Cadence
UInt8
to Gouint8
- Cadence
UInt16
to Gouint16
- Cadence
UInt32
to Gouint32
- Cadence
UInt64
to Gouint64
- Cadence
UInt128
to Go*big.Int
- Cadence
UInt256
to Go*big.Int
- Cadence
Fix64
to Goint64
- Cadence
UFix64
to Gouint64
- Cadence
String
to Gostring
- Cadence
Path
to Gostring
- Cadence
Address
to Gostring
orcadence.Address
or[8]uint8
- Cadence
Bool
to Gobool
- Cadence
Array
to Goslice
- Cadence
Struct
to Gostruct
- Cadence
Character
to Gostring
- Cadence
Resource
to Gostruct
- Cadence
Dictionary
to Gomap
- Cadence
Event
to Gostruct