Skip to content

Commit

Permalink
Update Bindings.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Akilan1999 authored Dec 16, 2023
1 parent 1c496d8 commit ea08b5c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions Docs/Bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
<br>

## How to build shared object files
The easier way
#### The easier way
```bash
# Run
make sharedObjects
```
Or the direct way
#### Or the direct way
```bash
# Run
cd Bindings && go build -buildmode=c-shared -o p2prc.so
```
If successfully built:
#### If successfully built:
```bash
# Enter into the Bindings directory
cd Bindings
Expand All @@ -40,12 +40,11 @@ Client.go
There a few things to notice which are different from
your standard Go programs:

1. We import "C" which means [Cgo](https://pkg.go.dev/cmd/cgo) is required.
#### 1. We import "C" which means [Cgo](https://pkg.go.dev/cmd/cgo) is required.
```go
import "C"
```
2. All functions which are required to be called from other programming languages
have comment such as.
#### 2. All functions which are required to be called from other programming languages have comment such as.
```go
//export <function name>

Expand All @@ -65,8 +64,7 @@ func StartContainer(IP string) (output *C.char) {
return ConvertStructToJSONString(container)
}
```
3. While looking through the file (If 2 files are compared
it is pretty trivial to notice a common structure).
#### 3. While looking through the file (If 2 files are compared it is pretty trivial to notice a common structure).
```go
// --------- Example ------------

Expand All @@ -89,7 +87,7 @@ func ViewPlugin() (output *C.char) {
}

```
It is easy to notice that:
#### It is easy to notice that:
- ```ConvertStructToJSONString(<go object>)```: This is a helper function that convert
a go object to JSON string initially and converts it to ```CString```.
- ```(output *C.char)```: This is the return type for most of the functions.
Expand Down

0 comments on commit ea08b5c

Please sign in to comment.