转到:编译单元测试时生成错误(我正在尝试模拟influxdb类型)

时间:2019-08-14 16:36:21

标签: macos go tdd influxdb

我只是从围棋语言开始。 我的小型项目成功从InfluxDB读取数据。 问题:当我将我的包(使用InfluxDB)导入我的单元测试包时,构建失败。

“生产”代码:

package data

import client "github.com/influxdata/influxdb1-client/v2"

func FunctionToTest() {}

// To make import necessary, unused for now
func createClient() (client.Client, error) {
    return client.NewHTTPClient(client.HTTPConfig{Addr: addr})
}

单元测试:

package data_test

import (
    "../data"
    "testing"
)

func TestSandBox(t *testing.T) {
    data.FunctionToTest()
}

我希望它可以编译/运行,但是:

# crypto/x509
In file included from /usr/local/go/src/crypto/x509/root_cgo_darwin.go:17:
In file included from /System/Library/Frameworks/Security.framework/Headers/Security.h:31:
/System/Library/Frameworks/Security.framework/Headers/SecItem.h:452:36: error: expected a version of the form 'major[.minor[.subminor]]'
    API_AVAILABLE(macos(10.7), ios(NA));
                                   ^
/usr/include/os/availability.h:61:181: note: expanded from macro 'API_AVAILABLE'
    #define API_AVAILABLE(...) __API_AVAILABLE_GET_MACRO(__VA_ARGS__,__API_AVAILABLE6, __API_AVAILABLE5, __API_AVAILABLE4, __API_AVAILABLE3, __API_AVAILABLE2, __API_AVAILABLE1, 0)(__VA_ARGS__)
                                                                                                                                                                                    ^
/usr/include/AvailabilityInternal.h:52025:54: note: expanded from macro '__API_AVAILABLE2'
    #define __API_AVAILABLE2(x,y) __API_A(x) __API_A(y)
                                                     ^
/usr/include/AvailabilityInternal.h:52023:79: note: expanded from macro '__API_A'
    #define __API_A(x) __attribute__((availability(__API_AVAILABLE_PLATFORM_##x)))
                                                                              ^
/usr/include/AvailabilityInternal.h:52018:60: note: expanded from macro '__API_AVAILABLE_PLATFORM_ios'
    #define __API_AVAILABLE_PLATFORM_ios(x) ios,introduced=x
                                                           ^

转到环境输出:

GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/johndoe/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/johndoe/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/4q/0yrdcxfd69x4mwzhvmwqg_gh0000gn/T/go-build020613348=/tmp/go-build -gno-record-gcc-switches -fno-common"

感谢您的帮助或建议。

0 个答案:

没有答案