Skip to content
This repository was archived by the owner on May 14, 2022. It is now read-only.

Commit a90bc93

Browse files
committed
chore: add example plugin
1 parent e827fc6 commit a90bc93

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

example/go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module github/getstackhead/pluginlib/example
2+
3+
go 1.17
4+
5+
require github.com/getstackhead/pluginlib v0.0.0
6+
7+
replace github.com/getstackhead/pluginlib => ../

example/go.sum

Whitespace-only changes.

example/main.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package main
2+
3+
import "fmt"
4+
import "github.com/getstackhead/pluginlib"
5+
6+
type MyPlugin struct {
7+
}
8+
9+
func (p MyPlugin) GetConfig() pluginlib.PluginConfig {
10+
return pluginlib.PluginConfig{
11+
Name: "Test",
12+
Description: "This is an example StackHead Proxy plugin",
13+
Version: "0.0.0-dev",
14+
Author: "Mario Lubenka",
15+
PluginType: pluginlib.PluginType.PROXY,
16+
}
17+
}
18+
19+
func (p MyPlugin) Deploy(project pluginlib.Project) {
20+
fmt.Println("Hello " + project.Name)
21+
}
22+
23+
func (p MyPlugin) Destroy(project pluginlib.Project) {
24+
fmt.Println("Bye " + project.Name)
25+
}
26+
27+
func (p MyPlugin) Setup() {
28+
fmt.Println("Setup...")
29+
}
30+
31+
var Plugin MyPlugin

example/main_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package main_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/getstackhead/pluginlib"
7+
)
8+
9+
func TestPluginLoading(t *testing.T) {
10+
loadedPlugin, err := pluginlib.LoadPlugin("./plugin_myplugin.so")
11+
if err != nil {
12+
t.Fatal("Unable to load plugin. Error occurred: " + err.Error())
13+
return
14+
}
15+
if loadedPlugin == nil {
16+
t.Fatal("Unable to load plugin. Plugin is nil")
17+
return
18+
}
19+
}

example/plugin_myplugin.so

3.27 MB
Binary file not shown.

0 commit comments

Comments
 (0)