https://github.com/pegvin/libappimage-go
Go Bindings For LibAppImage
https://github.com/pegvin/libappimage-go
Last synced: 7 months ago
JSON representation
Go Bindings For LibAppImage
- Host: GitHub
- URL: https://github.com/pegvin/libappimage-go
- Owner: pegvin
- License: mit
- Created: 2022-03-22T11:18:23.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-01-28T16:12:54.000Z (over 3 years ago)
- Last Synced: 2024-12-27T21:14:16.329Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LibAppImage Go
Go Bindings For LibAppImage
---
### Usage
Make sure to first make a new binding:
```go
myBinding, err := libappimagego.NewLibAppImageBindings()
```
And this is some extra stuff for storing appimage & debug flag
```go
appImagePath, debug := "/home/aditya/test.appimage", false
```
#### API
##### `(bind *libAppImageBind) Register(filePath string, debug bool) (error)`
Register the appimage from the given path to system, registering here is a term which can be used interchangeably with integrating.
```go
err := myBinding.Register(appImagePath, debug)
if err != nil {
panic(err)
}
```
##### `(bind *libAppImageBind) UnRegister(filePath string, debug bool) (error)`
UnRegister/De-Integrate the appimage from the given path from system.
```go
err := myBinding.UnRegister(appImagePath, debug)
if err != nil {
panic(err)
}
```
##### `(bind *libAppImageBind) ShallAppImageBeRegistered(filePath string) (bool)`
Returns a boolean representing if the AppImage Distributor/Author wants the appimage to be integrated to system or not.
```go
shallBeRegistered := myBinding.ShallAppImageBeRegistered(appImagePath)
if shallBeRegistered {
doSomething()
}
```
##### `(bind *libAppImageBind) IsRegistered(filePath string) (bool)`
Returns a boolean representing if the appimage is registered/integrated or not.
```go
isRegistered := myBinding.IsRegistered(appImagePath)
if isRegistered {
doSomething()
}
```
##### `(bind *libAppImageBind) IsTerminalApp(filePath string) (bool)`
Returns a boolean representing if the appimage is a terminal app or not.
```go
isTerminalApp := myBinding.IsTerminalApp(appImagePath)
if isTerminalApp {
doSomething()
}
```
##### `(bind *libAppImageBind) GetType(filePath string, debug bool) (int)`
Returns a integer representing the type of the appimage, 0 means Legacy, 1 means type 1, 2 means type 2 & -1 means invalid appimage. [Read More About AppImage Types](https://github.com/AppImage/AppImageSpec/blob/master/draft.md#image-format). LibAppImage Go provides constants to make to code more readable.
```go
appimageType := myBinding.GetType(appImagePath, debug)
if appimageType == libappimagego.APPIMAGE_TYPE_LEGACY {
doSomething()
} else if appimageType == APPIMAGE_TYPE_1 {
doSomething()
} else if appimageType == APPIMAGE_TYPE_2 {
doSomething()
} else if appimageType == APPIMAGE_TYPE_INVALID {
doSomething()
}
```
##### `(bind *libAppImageBind) Close()`
Make sure to call the `Close()` method so that it closes the bindings.
```go
myBinding.Close()
```
---
## Thanks