-
Notifications
You must be signed in to change notification settings - Fork 121
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
go cover不能生成可编译的打桩代码 #352
Comments
hi @LeonSu070 , The For experiencing the desired feature, I recommend using the |
Hi @CarlJi , Thanks for your response! Actually, we are running our service on AWS Lambda. That means we use AWS I changed the generated source code manually like the following steps, it can be built by
//line /Users/leonsulicun/LeonDisk/chopeGit/test/simple-go-server/main.go:1
package main;
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
"sync/atomic"
"time"
"simple-server/cover"
)
type key int
const (
requestIDKey key = 0
)
var (
Version string = ""
GitTag string = ""
GitCommit string = ""
GitTreeState string = ""
listenAddr string
healthy int32
)
func main() {cover.GoCover_0_623462353261316139306530.Count[0]++;
flag.StringVar(&listenAddr, "listen-addr", ":5001", "server listen address")
flag.Parse()
logger := log.New(os.Stdout, "http: ", log.LstdFlags)
logger.Println("Simple go server")
logger.Println("Version:", Version)
logger.Println("GitTag:", GitTag)
logger.Println("GitCommit:", GitCommit)
logger.Println("GitTreeState:", GitTreeState)
logger.Println("Server is starting...")
router := http.NewServeMux()
router.Handle("/", index())
router.Handle("/healthz", healthz())
nextRequestID := func() string {cover.GoCover_0_623462353261316139306530.Count[4]++;
return fmt.Sprintf("%d", time.Now().UnixNano())
}
cover.GoCover_0_623462353261316139306530.Count[1]++;server := &http.Server{
Addr: listenAddr,
Handler: tracing(nextRequestID)(logging(logger)(router)),
ErrorLog: logger,
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 15 * time.Second,
}
... |
@LeonSu070 Certainly, let's add it to the backlog. Thank you! |
Thanks! |
执行goc cover生成打桩代码
执行命令:
生成了cover.go和http_cover_apis_auto_generated.go
运行打好桩的代码报错
生成的代码:
cover.go
http_cover_apis_auto_generated.go
main.go
go.mod
The text was updated successfully, but these errors were encountered: