consts_gen_service_template.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved.
  2. //
  3. // This Source Code Form is subject to the terms of the MIT License.
  4. // If a copy of the MIT was not distributed with this file,
  5. // You can obtain one at https://github.com/gogf/gf.
  6. package consts
  7. const TemplateGenServiceContentHead = `
  8. // ================================================================================
  9. // Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
  10. // You can delete these comments if you wish manually maintain this interface file.
  11. // ================================================================================
  12. package {PackageName}
  13. {Imports}
  14. `
  15. const TemplateGenServiceContentInterface = `
  16. {InterfaceName} interface {
  17. {FuncDefinition}
  18. }
  19. `
  20. const TemplateGenServiceContentVariable = `
  21. local{StructName} {InterfaceName}
  22. `
  23. const TemplateGenServiceContentRegister = `
  24. func {StructName}() {InterfaceName} {
  25. if local{StructName} == nil {
  26. panic("implement not found for interface {InterfaceName}, forgot register?")
  27. }
  28. return local{StructName}
  29. }
  30. func Register{StructName}(i {InterfaceName}) {
  31. local{StructName} = i
  32. }
  33. `