Giter VIP home page Giter VIP logo

zhufuyi / sponge Goto Github PK

View Code? Open in Web Editor NEW
1.1K 1.1K 104.0 14.92 MB

Sponge is a powerful Go development framework, it's easy to develop web and microservice projects.

Home Page: https://go-sponge.com

License: MIT License

Makefile 0.62% Go 90.36% Shell 8.83% Dockerfile 0.13% HTML 0.05% JavaScript 0.01%
architecture crud development-framework generate-code gin go golang grpc grpc-gateway microservice-framework microservices restful-api rpc sponge web

sponge's People

Contributors

cbot918 avatar gitter-badger avatar hanwenbo avatar zhufuyi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sponge's Issues

Mac M1 install sponge failed

Describe the bug
Mac M1 install sponge failed

The error is

 > go install github.com/zhufuyi/sponge/cmd/sponge@latest
 # github.com/shoenig/go-m1cpu
 ../../pkg/mod/github.com/shoenig/[email protected]/cpu.go:65:33: error: use of undeclared identifier 'kIOMainPortDefault'; did you mean 'kIOMasterPortDefault'?
    IOServiceGetMatchingServices(kIOMainPortDefault, matching, &iter);
                                 ^~~~~~~~~~~~~~~~~~
                                 kIOMasterPortDefault
 /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/IOKit.framework/Headers/IOKitLib.h:103:19: note: 'kIOMasterPortDefault' declared here
 const mach_port_t kIOMasterPortDefault;
  • OS: MacOS 11.2.3

集成组件更新

sponge是一个很优秀的开发框架,提供了多种内置组件和快速开发方式。不过内置的组件较多来带的问题是:如果涉及到内置组件,比如gin或Consul的版本更新,请问这种组件更新一般如何处理比较好?如果直接使用更新组件版本是否会影响sponge框架逻辑?

大佬能做成类似gin vue admin 内种 带页面的吗,快速开发脚手架

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

go install sponge error

Describe the bug
https://go-sponge.com/zh-cn/quick-start?id=%e5%ae%89%e8%a3%85-sponge
根据文档的安装步骤,安装sponge的时候报错。

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is
 go version

 go version go1.20.4 darwin/arm64
  1. The error is
go install github.com/zhufuyi/sponge/cmd/sponge@latest

# github.com/zhufuyi/sponge/cmd/sponge
ld: warning: '/private/var/folders/jx/41jbkxb92y7cmh1cs8kznr6w0000gn/T/go-link-3333539147/go.o' has malformed LC_DYSYMTAB, expected 129 undefined symbols to start at index 43311, found 221 undefined symbols starting at index 76

有使用过goframe吗?

有使用过goframe吗?某些功能可能使用gf 更容易实现

考虑出一版基于goframe的不

on ubuntu, "sponge init" got chmod issue, it probably used some wrong linux command

sponge init

initialize sponge ......
✔ upgraded sponge binary.
❌ upgrade template code.
Error: execute command failed, /bin/chmod: cannot access '/home/eric/.sponge/api': Permission denied
/bin/chmod: cannot access '/home/eric/.sponge/go.sum': Permission denied
/bin/chmod: cannot access '/home/eric/.sponge/doc.go': Permission denied
/bin/chmod: cannot access '/home/eric/.sponge/internal': Permission denied

Then I checked the permission of ~/.sponge, it's mess:

eric@eric-pc:~$ ll .sponge/
ls: cannot access '.sponge/api': Permission denied
ls: cannot access '.sponge/go.sum': Permission denied
ls: cannot access '.sponge/doc.go': Permission denied
ls: cannot access '.sponge/internal': Permission denied
ls: cannot access '.sponge/Makefile-for-http': Permission denied
ls: cannot access '.sponge/Makefile': Permission denied
ls: cannot access '.sponge/.gitignore': Permission denied
ls: cannot access '.sponge/third_party': Permission denied
ls: cannot access '.sponge/cmd': Permission denied
ls: cannot access '.sponge/.': Permission denied
ls: cannot access '.sponge/docs': Permission denied
ls: cannot access '.sponge/codecov.yml': Permission denied
ls: cannot access '.sponge/..': Permission denied
ls: cannot access '.sponge/.golangci.yml': Permission denied
ls: cannot access '.sponge/scripts': Permission denied
ls: cannot access '.sponge/Jenkinsfile': Permission denied
ls: cannot access '.sponge/deployments': Permission denied
ls: cannot access '.sponge/examples': Permission denied
ls: cannot access '.sponge/test': Permission denied
ls: cannot access '.sponge/LICENSE': Permission denied
ls: cannot access '.sponge/configs': Permission denied
ls: cannot access '.sponge/README.md': Permission denied
ls: cannot access '.sponge/go.mod': Permission denied
ls: cannot access '.sponge/.github': Permission denied
ls: cannot access '.sponge/pkg': Permission denied
ls: cannot access '.sponge/assets': Permission denied
total 0
d????????? ? ? ? ?            ? ./
d????????? ? ? ? ?            ? ../
d????????? ? ? ? ?            ? api/
d????????? ? ? ? ?            ? assets/
d????????? ? ? ? ?            ? cmd/
-????????? ? ? ? ?            ? codecov.yml
d????????? ? ? ? ?            ? configs/
d????????? ? ? ? ?            ? deployments/
-????????? ? ? ? ?            ? doc.go
d????????? ? ? ? ?            ? docs/
d????????? ? ? ? ?            ? examples/
d????????? ? ? ? ?            ? .github/
-????????? ? ? ? ?            ? .gitignore
-????????? ? ? ? ?            ? .golangci.yml
-????????? ? ? ? ?            ? go.mod
-????????? ? ? ? ?            ? go.sum
d????????? ? ? ? ?            ? internal/
-????????? ? ? ? ?            ? Jenkinsfile
-????????? ? ? ? ?            ? LICENSE
-????????? ? ? ? ?            ? Makefile
-????????? ? ? ? ?            ? Makefile-for-http
d????????? ? ? ? ?            ? pkg/
-????????? ? ? ? ?            ? README.md
d????????? ? ? ? ?            ? scripts/
d????????? ? ? ? ?            ? test/
d????????? ? ? ? ?            ? third_party/

无法正确安装指定的版本

Describe the bug
通过go install方式安装指定版本时,始终都会自动安装最新的版本,例如:

[dev@dev bin]$ go install github.com/zhufuyi/sponge/cmd/[email protected]
go: github.com/zhufuyi/sponge/cmd/[email protected]: github.com/zhufuyi/sponge/cmd/[email protected]: invalid version: unknown revision 1.8.0
[dev@dev bin]$ go install github.com/zhufuyi/sponge/cmd/[email protected]
go: downloading github.com/zhufuyi/sponge v1.8.0
go: downloading github.com/huandu/xstrings v1.3.3
[dev@dev bin]$ sponge -v
sponge version v1.8.1

Environments (please complete the following information):

  • OS: CentOS Linux 7 (Core)
  • sponge version 1.8.0

More description
none

填写MySQL的DSN后无法获取表名

我在阿里服务器搭建了sponge和MySQL,数据库已经建立好,按照格式填写好DSN后无法获取表名,无论是内网地址,本地地址,外网地址都不行,我电脑使用Python脚本测试可以远程连接到MySQL数据库,Go版本1.22.4

数据为枚举类型时出错,无法使用

2024/06/08 21:53:53 Error parsing type definition 'types.ListObjDetail': cannot find type definition: UnSupport
2024/06/08 21:53:53 Error parsing type definition 'types.GetListByIDRespond': cannot find type definition: UnSupport
2024/06/08 21:53:53 ParseComment error in file /home/panda/Projects/web/tiku-web-http-214418/internal/handler/list.go :cannot find type definition: UnSupport
make: *** [Makefile:43: docs] Error 1

如何使用goland运行和Debug生成出来的项目

Is your feature request related to a problem? Please describe.
刚刚接触到go语言,想了解一下如何在goland中运行和debug生成出来的项目,目前配置好会报grep错误,我猜测可能是goland默认终端使用的是cmd,而不是cmder。

Describe the solution you'd like
A clear and concise description of what you want to happen.
我想在goland中直接运行生产出来的项目
目前我的配置
image
运行时报的错
image

创建http-pb项目时,make proto命令出现错误

Describe the bug

我在通过命令创建项目时,make proto出现错误。

执行的命令如下:

  1. sponge web http-pb --module-name=tidy --server-name=tidy --project-name=tidy --protobuf-file=./tidy.proto --out=./generate

  2. sponge web handler-pb --db-dsn='root:123456@(127.0.0.1:3306)/tidy' --db-table=task,target --out=./generate --module-name=github.com/Rvn0xsy/tidy

在执行第二条命令时,出现如下错误:

go: found github.com/zhufuyi/sponge/pkg/gin/validator in github.com/zhufuyi/sponge v1.5.0
go: found github.com/zhufuyi/sponge/pkg/jwt in github.com/zhufuyi/sponge v1.5.0
go: found github.com/zhufuyi/sponge/pkg/gotest in github.com/zhufuyi/sponge v1.5.0
go: found github.com/zhufuyi/sponge/pkg/gofile in github.com/zhufuyi/sponge v1.5.0
gofmt -s -w .
api/types/types.proto: File not found.
api/tidy/v1/target.proto:5:1: Import "api/types/types.proto" was not found or had errors.
api/tidy/v1/target.proto:231:3: "types.Params" is not defined.
make: *** [Makefile:81:proto] 错误 1

我的tidy.proto文件内容如下:

syntax = "proto3";

package api.tidy.v1;

import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

option go_package = "tidy/api/user/v1;v1";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
  host: "localhost:8080"
  base_path: ""
  info: {
    title: "user api docs";
    version: "2.0";
  };
  schemes: HTTP;
  schemes: HTTPS;
  consumes: "application/json";
  produces: "application/json";
};

service user {
  rpc Login(LoginRequest) returns (LoginReply) {
    option (google.api.http) = {
      post: "/api/v1/login"
      body: "*"
    };
    option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
      summary: "登录",
      description: "使用邮箱登录",
    };
  }
}

message LoginRequest {
  string email = 1;
  string password = 2;
}

message LoginReply {
  string token = 1;
}

根据大致意思能够了解到,是Import "api/types/types.proto" 这个文件缺失,这个文件貌似没有生成。

sponge的版本:

$ sponge -v
sponge version v1.5.0

评价

功能挺好,代码挺乱!

能不能将生成代码的功能拆分成一个工具,独立使用

我有一个类似的功能, 直接用 golang 定义接口然后生成代码
https://github.com/mei-rune/gogen/blob/master/intro.md

但是我不喜欢它, 当初也想过用 protoc 生成, 但因为已有功能的原因没有用 protoc , 现在发现了这个,请问能不能将 代码生成拆分出来, 成为一个独立的工具。
这样子,我们可以在原来的框架下无痛引入这个工具来提高效率。

代码生成为空文件夹

按照文档生成项目结构目录,文件下载后解压为空文档。
按照安装流程对比了几次,没有发现缺漏步骤,不知是什么问题,或者哪里可以看到文件生成的日志。

logger WithFields打印的目录不对

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

下载代码报错

根据sql生成web服务,点击下载代码提示
Internal Server Error, exec: "sponge": cannot run executable found relative to current directory

  • OS: WIn11
  • sponge version 1.5.16

移除表前缀

Is your feature request related to a problem? Please describe.
表 ue_proxy希望生成的model等,不使用UeProxy而是使用Proxy,不要Ue前缀

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

sponge init panic

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is
go version go1.21.0 darwin/arm64
  1. The error is
sponge init
panic: cgroup cpu init failed!err:=not implemented yet

goroutine 1 [running]:
github.com/zhufuyi/sponge/pkg/shield/cpu.init.0()
	/Users/user/go/pkg/mod/github.com/zhufuyi/[email protected]/pkg/shield/cpu/stat.go:33 +0xfc

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environments (please complete the following information):

  • OS: [mac os]
  • sponge version [1.5.5]

More description
Add any other context about the problem here.

一定要go1.20版本?

go.opentelemetry.io/otel/internal/global

../../../golang/pkg/mod/go.opentelemetry.io/[email protected]/internal/global/handler.go:44:18: undefined: atomic.Pointer
../../../golang/pkg/mod/go.opentelemetry.io/[email protected]/internal/global/internal_logging.go:30:25: undefined: atomic.Pointer
note: module requires Go 1.20

Screenshots
If applicable, add screenshots to help explain your problem.

Environments (please complete the following information):

  • OS: [e.g. Linux]
  • sponge version [e.g. 1.1.1]

More description
Add any other context about the problem here.

有一个小疑问。。

在视频中我看到比方说有三个rpc服务,一个网关服务,然后通过网关服务去调用rpc服务。
如果我有这样一个需求,我不需要网关服务,我有一个protobuff生成的web服务,里面都是暴露给前台的接口,这个时候我其中一个接口想调用一个rpc服务,这个可以通过代码自动生成去实现么?

如果可以的话还有一个问题,比方说名称相同的情况,web服务有一个叫user.proto文件而rpc服务中也有一个叫user.proto的文件,当然,如果两个服务都是同一个项目组去做可以通过命名的方式去做区分,但是也有可能是两个不同的项目组,这样同名的情况应该怎么办?

基于sql创建web报错,

填写表单,后点 下载代码 报错

The error is

Internal Server Error, exec: "sponge": cannot run executable found relative to current directory

使用postgres数据库床建一个项目失败

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is

  2. The error is
    有可能是数据库字段类型的错误?

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.
image
image

Environments (please complete the following information):

  • OS: windows
  • sponge version v1.6.2

More description
Add any other context about the problem here.
如图所示

Time.Now 数据库字段datetime

Describe the bug
Time.Now 数据库字段datetime ,在dao结构体中gorm是指针,但是test文件里面是给的不是地址

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is

  2. The error is

    
    

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environments (please complete the following information):

  • OS: [e.g. Linux]
  • sponge version [e.g. 1.1.1]

More description
Add any other context about the problem here.

sponge init 失败

$ sponge init
initialize sponge ......
❌ upgrade sponge binary.
Error: go: github.com/zhufuyi/sponge/cmd/sponge@latest: module github.com/zhufuyi/sponge/cmd/sponge: Get "https://proxy.golang.org/github.com/zhufuyi/sponge/cmd/sponge/@v/list": dial tcp 172.217.160.113:443: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

生成文档时swag会报错

Describe the bug
生成文档时swag会报错

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The code is

// @title ChatGPT_MJ_aggregation_next api docs
// @description http server api docs
// @schemes http https
// @Version 2.0
// @host localhost:8080
// @securityDefinitions.apikey BearerAuth
// @in header
// @name Authorization
// @description "Type Bearer your-jwt-token" to Value
func main() {
initial.InitApp()
services := initial.CreateServices()
closes := initial.Close(services)

a := app.New(services, closes)
a.Run()

}

2. The error is

// @description "Type Bearer your-jwt-token" to Value

3.将// @description "Type Bearer your-jwt-token" to Value 改成
// @description Type Bearer your-jwt-token to Value  可以解决

建议支持pgsql

建议支持下pgsql,或完全兼容gorm所支持的那几种数据库

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.