10 examples of 'interface in go lang' in Go

Every line of 'interface in go lang' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Go code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
36func togo(obj *C.PyObject) *PyObject {
37 switch obj {
38 case nil:
39 return nil
40 case Py_None.ptr:
41 return Py_None
42 case Py_True.ptr:
43 return Py_True
44 case Py_False.ptr:
45 return Py_False
46 default:
47 return &PyObject{ptr: obj}
48 }
49}
599func cgoIsGoPointer(p unsafe.Pointer) bool {
600 if p == nil {
601 return false
602 }
603
604 if cgoInRange(p, mheap_.arena_start, mheap_.arena_used) {
605 return true
606 }
607
608 for datap := &firstmoduledata; datap != nil; datap = datap.next {
609 if cgoInRange(p, datap.data, datap.edata) || cgoInRange(p, datap.bss, datap.ebss) {
610 return true
611 }
612 }
613
614 return false
615}
46func golibLI_I(a1 int64, a2 int32) int32 {
47 return int32(a1) - a2
48}
95func (h *CErrorHandler) ConvertGoInt(iError int) error {
96 return h.Convert(C.int(iError))
97}
191func (m *method) ArgToGo(n int) string {
192 return m.typeToGo(m.argTypes[n], m.args[n])
193}
17func Go2ResultType(extTypes map[string]types.TypeRegistration, useString bool, goType string) (hardToAccessResultType, error) {
18 var res hardToAccessResultType
19 if goType == "string" {
20 if useString {
21 return hardToAccessResultType("string"), nil
22 }
23 return hardToAccessResultType("[]byte"), nil
24 } else {
25 if types.IsBuiltin(goType) {
26 fieldType := types.Builtin("", goType)
27 return hardToAccessResultType(fieldType.GoName()), nil
28 }
29 ext, ok := extTypes[goType]
30 if !ok {
31 return res, fmt.Errorf("unsupported type `\033[1m%s\033[0m`", goType)
32 }
33 return hardToAccessResultType(ext.String()), nil
34 }
35}
28func CallIface(v Iface) {
29 cpkg.Printf("iface.CallIface...\n")
30 v.F()
31 cpkg.Printf("iface.CallIface... [DONE]\n")
32}
185func getGoInt(th object.Thread, tab object.Table, key string) (int, *object.RuntimeError) {
186 val := tab.Get(object.String(key))
187 if val == nil {
188 return 0, object.NewRuntimeError(fmt.Sprintf("field '%s' missing in date table", key))
189 }
190 if i, ok := object.ToGoInt(val); ok {
191 return i, nil
192 }
193 return 0, object.NewRuntimeError(fmt.Sprintf("field '%s' is not an integer", key))
194}
514func (L *State) ToGoFunction(index int) (f LuaGoFunction) {
515 if !L.IsGoFunction(index) {
516 return nil
517 }
518 fid := C.clua_togofunction(L.s, C.int(index))
519 if fid < 0 {
520 return nil
521 }
522 return L.registry[fid].(LuaGoFunction)
523}
87func (v View) GoEmptyReturnType(str string) string {
88 if v.IsEnum(str) {
89 return "gdnative.NewEmptyInt"
90 }
91 str = strings.Replace(str, "*", "", 1)
92 str = strings.TrimSpace(str)
93
94 if v.IsGodotClass(str) {
95 return "gdnative.NewEmptyObject"
96 } else {
97 return "gdnative.NewEmpty" + v.GoName(str)
98 }
99}

Related snippets