小编Ryk*_*yke的帖子

golangci-lint 未声明的名称:`getProxyURL`(类型检查)

我是 golang 新手,我正在尝试测试我的代理函数,测试正确通过,但是在运行 golangci 时,它给了我错误:

未声明的名称:(getProxyURL类型检查) if got := getProxyURL(tt.args.campaignCode, urls); 得到!= tt.想要 { ^

func getProxyURL(campaignCode string, urls map[string]string) string {
   if campaignURL, ok := urls[campaignCode]; ok {
      return campaignURL
   }
   return "https://facebook.com"
}
Run Code Online (Sandbox Code Playgroud)

_测试

package main

import "testing"

func Test_getProxyURL(t *testing.T) {
   type args struct {
      campaignCode string
   }
   urls := make(map[string]string, 0)
   urls["82383b80-056b-42e8-b192-9b0f33c4f46e"] = "https://google.com"
   urls["negativeTest"] = "https://facebook.com"

   tests := []struct {
      name string
      args args
      want string
   }{
      {
         name: "Given an invalid campaign …
Run Code Online (Sandbox Code Playgroud)

typechecking go golangci-lint

5
推荐指数
0
解决办法
921
查看次数

标签 统计

go ×1

golangci-lint ×1

typechecking ×1