github.com/turingchain2020/turingchain@v1.1.21/cmd/tools/gencode/dappcode/plugin.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package dappcode 6 7 import ( 8 "github.com/turingchain2020/turingchain/cmd/tools/gencode/base" 9 "github.com/turingchain2020/turingchain/cmd/tools/types" 10 ) 11 12 func init() { 13 14 base.RegisterCodeFile(pluginCodeFile{}) 15 } 16 17 type pluginCodeFile struct { 18 base.DappCodeFile 19 } 20 21 func (c pluginCodeFile) GetFiles() map[string]string { 22 23 return map[string]string{ 24 pluginName: pluginContent, 25 } 26 } 27 28 func (c pluginCodeFile) GetFileReplaceTags() []string { 29 30 return []string{types.TagExecName, types.TagImportPath, types.TagClassName} 31 } 32 33 var ( 34 pluginName = "plugin.go" 35 pluginContent = ` 36 package types 37 38 import ( 39 "${IMPORTPATH}/${EXECNAME}/commands" 40 ${EXECNAME}types "${IMPORTPATH}/${EXECNAME}/types" 41 "${IMPORTPATH}/${EXECNAME}/executor" 42 "${IMPORTPATH}/${EXECNAME}/rpc" 43 "github.com/turingchain2020/turingchain/pluginmgr" 44 ) 45 46 /* 47 * 初始化dapp相关的组件 48 */ 49 50 func init() { 51 pluginmgr.Register(&pluginmgr.PluginBase{ 52 Name: ${EXECNAME}types.${CLASSNAME}X, 53 ExecName: executor.GetName(), 54 Exec: executor.Init, 55 Cmd: commands.Cmd, 56 RPC: rpc.Init, 57 }) 58 }` 59 )