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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why net.Addr is fiber.testAddr, not *net.TCPAddr?馃 #1574

fiecato opened this issue Oct 14, 2021 · 5 comments 路 Fixed by #1784

Why net.Addr is fiber.testAddr, not *net.TCPAddr?馃 #1574

fiecato opened this issue Oct 14, 2021 · 5 comments 路 Fixed by #1784


Copy link

fiecato commented Oct 14, 2021

Question description
I use app.Test for unit testing, but panic: interface conversion: net.Addr is fiber.testAddr, not *net.TCPAddr is reported

Code snippet Optional

initialize.go of InitTrancer

func InitTracer() (closer io.Closer) {
	global.Tracer, closer, _ = ot.NewJaegerTracer("fxs-api", global.Jaeger.Agent)
	return closer


package router

import (

func SetupRouter(app *fiber.App) {
        recover.ConfigDefault.EnableStackTrace = true
	// Tracing
	midRouter := middleware.ValidateToken(global.TokenService, global.AutoExpireMinutes)

	V0AdminRouter := app.Group("fxs/v0/admin")

        V0AdminRouter.Get("/dealers", midRouter, dealers.ListDealer)


// AccessLog record request code
func AccessLog() fiber.Handler {
	return func(c *fiber.Ctx) error {
		startTime := time.Now()
		chainErr := c.Next()
		if chainErr != nil {
			FiberErrorHandler(c, chainErr)
		endTime := time.Now()
			zap.String("method", c.Method()),
			zap.String("ip", c.IP()),
			zap.String("port", c.Port()),
			zap.Int("status", c.Response().StatusCode()),
			zap.String("user-agent", string(c.Request().Header.UserAgent())),
			zap.Any("errors", chainErr),
			zap.Duration("cost", endTime.Sub(startTime).Round(time.Millisecond)),
		return nil

package tests

import ""

var app = &fiber.App{}

func init() {
        closer := initialize.InitTracer()
	defer closer.Close()
        app = fiber.New(fiber.Config{
		Prefork:       false,
		CaseSensitive: true,
		StrictRouting: true,
		AppName:       "fxs-pai",
		ErrorHandler:  utils.GlobalErrorHandler,


func TestListDealer(t *testing.T) {
	tests := []struct {
		name    string
		route   string
		wantErr bool
			name:    "test list dealer with only pageSize",
			route:   "/fxs/v0/admin/dealers?pageSize=10",
			wantErr: false,
	for _, tt := range tests {
		req := httptest.NewRequest(http.MethodGet, tt.route, nil)
		resp, err := app.Test(req, -1)
        if err != nil {
            t.Errorf("%s of %s failed:%v",, tt.route, err)
        if (resp.StatusCode != http.StatusOK) != tt.wantErr {
            t.Errorf("%s response failed: %v",, resp)

How should I deal with this situation?

Copy link

welcome bot commented Oct 14, 2021

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord

Copy link

Vytek commented Feb 17, 2022

Hello, I have the same error. How can I fix it??

Copy link

ReneWerner87 commented Feb 18, 2022

@Vytek @fiecato
this error is not easy to recreate

have tried it with the code snippets, however, I see no error

would it be possible for someone to provide a minimal main and test file where this problem occurs?

with all the resources that are needed

Copy link

Vytek commented Feb 18, 2022

Hi @ReneWerner87,
I recreate the error and develop a little repo with all.

This is the public repo with all the code:

We test the error on:

Distributor ID: Ubuntu
Description: Ubuntu 20.04.3 LTS
Release: 20.04
Codename: focal

Go Version:

go version go1.17.6 linux/amd64

Thank you very much!

Copy link

ReneWerner87 commented Feb 18, 2022

thanks for the example, now i see the problem and will work on a fix

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

Successfully merging a pull request may close this issue.

3 participants