-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance default_extension_go for template mode (#88)
Co-authored-by: Hu Yueh-Wei <[email protected]>
- Loading branch information
1 parent
63312bc
commit 75ec478
Showing
10 changed files
with
213 additions
and
10 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
29 changes: 29 additions & 0 deletions
29
packages/core_extensions/default_extension_go/README-CN.md
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,29 @@ | ||
# default_extension_go | ||
|
||
<!-- 一句话介绍 --> | ||
|
||
## 主要功能 | ||
|
||
<!-- 主要功能介绍 --> | ||
|
||
- XXX 功能 | ||
|
||
## API | ||
|
||
参考 [manifest.json](manifest.json) 中的 `api` 定义及 [property.json](property.json) 中的默认值。 | ||
|
||
<!-- 注:API 需要额外说明时,可以在此进行更详细的描述,或者 link 到额外的 API-CN.md 文档 --> | ||
|
||
## 本地开发 | ||
|
||
### 构建 | ||
|
||
<!-- 构建说明 --> | ||
|
||
### Unit test | ||
|
||
<!-- 单元测试说明 --> | ||
|
||
## 其他 | ||
|
||
<!-- 其他相关介绍 --> |
29 changes: 29 additions & 0 deletions
29
packages/core_extensions/default_extension_go/README-CN.md.tent
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,29 @@ | ||
# {{package_name}} | ||
|
||
<!-- 一句话介绍 --> | ||
|
||
## 主要功能 | ||
|
||
<!-- 主要功能介绍 --> | ||
|
||
- XXX 功能 | ||
|
||
## API | ||
|
||
参考 [manifest.json](manifest.json) 中的 `api` 定义及 [property.json](property.json) 中的默认值。 | ||
|
||
<!-- 注:API 需要额外说明时,可以在此进行更详细的描述,或者 link 到额外的 API-CN.md 文档 --> | ||
|
||
## 本地开发 | ||
|
||
### 构建 | ||
|
||
<!-- 构建说明 --> | ||
|
||
### Unit test | ||
|
||
<!-- 单元测试说明 --> | ||
|
||
## 其他 | ||
|
||
<!-- 其他相关介绍 --> |
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,29 @@ | ||
# default_extension_go | ||
|
||
<!-- brief introduction for the extension --> | ||
|
||
## Features | ||
|
||
<!-- main features introduction --> | ||
|
||
- xxx feature | ||
|
||
## API | ||
|
||
Refer to `api` definition in [manifest.json] and default values in [property.json](property.json). | ||
|
||
<!-- Additional API.md can be referred to if extra introduction needed --> | ||
|
||
## Development | ||
|
||
### Build | ||
|
||
<!-- build dependencies and steps --> | ||
|
||
### Unit test | ||
|
||
<!-- how to do unit test for the extension --> | ||
|
||
## Misc | ||
|
||
<!-- others if applicable --> |
29 changes: 29 additions & 0 deletions
29
packages/core_extensions/default_extension_go/README.md.tent
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,29 @@ | ||
# {{package_name}} | ||
|
||
<!-- brief introduction for the extension --> | ||
|
||
## Features | ||
|
||
<!-- main features introduction --> | ||
|
||
- xxx feature | ||
|
||
## API | ||
|
||
Refer to `api` definition in [manifest.json] and default values in [property.json](property.json). | ||
|
||
<!-- Additional API.md can be referred to if extra introduction needed --> | ||
|
||
## Development | ||
|
||
### Build | ||
|
||
<!-- build dependencies and steps --> | ||
|
||
### Unit test | ||
|
||
<!-- how to do unit test for the extension --> | ||
|
||
## Misc. | ||
|
||
<!-- others if applicable --> |
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
57 changes: 57 additions & 0 deletions
57
packages/core_extensions/default_extension_go/extension.go.tent
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,57 @@ | ||
// | ||
// This file is part of TEN Framework, an open source project. | ||
// Licensed under the Apache License, Version 2.0. | ||
// See the LICENSE file for more information. | ||
// | ||
// Note that this is just an example extension written in the GO programming | ||
// language, so the package name does not equal to the containing directory | ||
// name. However, it is not common in Go. | ||
// | ||
|
||
package {{package_name}} | ||
|
||
import ( | ||
"fmt" | ||
|
||
"ten_framework/ten" | ||
) | ||
|
||
type {{class_name_prefix}}Extension struct { | ||
ten.DefaultExtension | ||
} | ||
|
||
func newExtension(name string) ten.Extension { | ||
return &{{class_name_prefix}}Extension{} | ||
} | ||
|
||
func (e *{{class_name_prefix}}Extension) OnStart(tenEnv ten.TenEnv) { | ||
tenEnv.LogDebug("OnStart") | ||
|
||
tenEnv.OnStartDone() | ||
} | ||
|
||
func (e *{{class_name_prefix}}Extension) OnStop(tenEnv ten.TenEnv) { | ||
tenEnv.LogDebug("OnStop") | ||
|
||
tenEnv.OnStopDone() | ||
} | ||
|
||
func (e *{{class_name_prefix}}Extension) OnCmd( | ||
tenEnv ten.TenEnv, | ||
cmd ten.Cmd, | ||
) { | ||
tenEnv.LogDebug("OnCmd") | ||
|
||
cmdResult, _ := ten.NewCmdResult(ten.StatusCodeOk) | ||
tenEnv.ReturnResult(cmdResult, cmd) | ||
} | ||
|
||
func init() { | ||
fmt.Println("{{package_name}} extension init") | ||
|
||
// Register addon | ||
ten.RegisterAddonAsExtension( | ||
"{{package_name}}", | ||
ten.NewDefaultExtensionAddon(newExtension), | ||
) | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module extension | ||
module default_extension_go | ||
|
||
go 1.18 | ||
|
||
|
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module extension | ||
module default_extension_go | ||
|
||
go 1.18 | ||
|
||
|