Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.9.3 版本构建出来的包大了很多 #1213

Open
outsrkem opened this issue Oct 16, 2024 · 2 comments
Open

v0.9.3 版本构建出来的包大了很多 #1213

outsrkem opened this issue Oct 16, 2024 · 2 comments

Comments

@outsrkem
Copy link

Describe the Question

v0.9.3 版本构建出来的包大了很多(40M左右)
v0.9.3到之前的 v0.8.1版本构建出来的包只有(17M左右)

Reproducible Code

func main() {
	h := server.Default(0.0.0.0:18888), server.WithExitWaitTime(0*time.Second))
	h.Spin()
}

Expected behavior

减小构建体积

Screenshots

image
image

Hertz version:
v0.9.3 v0.9.2

Environment:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE=''
GOPROXY='https://goproxy.cn,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/opt/src/uias/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2696052168=/tmp/go-build -gno-record-gcc-switches'

Additional context

@conero
Copy link

conero commented Oct 25, 2024

因为好奇也做了一个与其他框架的对比基础的 hello,打包下来确实太大。如果用来做简单的服务有点重了

package main

import (
	"conero.cn/rockb/server/internal/handler"
	"context"
	"github.com/cloudwego/hertz/pkg/app"
	"github.com/cloudwego/hertz/pkg/app/server"
	"github.com/cloudwego/hertz/pkg/protocol/consts"
)

func main() {
	sv := server.Default()
	sv.GET("/ping", func(ctx context.Context, c *app.RequestContext) {
		c.JSON(consts.StatusOK, handler.Ping())
	})
	sv.GET("/", func(c context.Context, ctx *app.RequestContext) {
		ctx.String(consts.StatusOK, "Hello, World!")
	})
	sv.Spin()
}

image

@xiaost
Copy link
Contributor

xiaost commented Oct 29, 2024

@outsrkem @conero Thanks for your feedback. We will review this case and get back to you later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants