-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add go plugin APIs and examples
Signed-off-by: peefy <[email protected]>
- Loading branch information
Showing
34 changed files
with
482 additions
and
346 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"kcl-lang.io/kcl-go/pkg/kcl" | ||
"kcl-lang.io/kcl-go/pkg/native" // Import the native API | ||
_ "kcl-lang.io/kcl-go/pkg/plugin/hello_plugin" // Import the hello plugin | ||
) | ||
|
||
func main() { | ||
// Note we use `native.MustRun` here instead of `kcl.MustRun`, because it needs the cgo feature. | ||
yaml := native.MustRun("main.k", kcl.WithCode(code)).GetRawYamlResult() | ||
fmt.Println(yaml) | ||
} | ||
|
||
const code = ` | ||
import kcl_plugin.hello | ||
name = "kcl" | ||
three = hello.add(1,2) | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.