github.com/searKing/golang/go@v1.2.117/runtime/cgo.go (about)

     1  // Copyright 2021 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package runtime
     6  
     7  import "unsafe"
     8  
     9  // BytesPointer returns a pointer which can be used by CGO
    10  func BytesPointer(data []byte) unsafe.Pointer {
    11  	if len(data) == 0 {
    12  		return nil
    13  	}
    14  	return unsafe.Pointer(&data[0])
    15  }