小编thi*_*rou的帖子

我应该如何在Go 1.6中使用供应商?

首先我读到了这个答案:在Go 1.6中提供,然后我用它作为我的例子.

我的gopath是GOPATH="/Users/thinkerou/xyz/",以及如下:

thinkerou@MacBook-Pro-thinkerou:~/xyz/src/ou$ pwd
/Users/baidu/xyz/src/ou
thinkerou@MacBook-Pro-thinkerou:~/xyz/src/ou$ ls
main.go vendor
Run Code Online (Sandbox Code Playgroud)

现在,我使用go get,然后成为这个:

thinkerou@MacBook-Pro-thinkerou:~/xyz/src/ou$ ls
main.go vendor
thinkerou@MacBook-Pro-thinkerou:~/xyz/src/ou$ cd vendor/
thinkerou@MacBook-Pro-thinkerou:~/xyz/src/ou/vendor$ ls
vendor.json
thinkerou@MacBook-Pro-thinkerou:~/xyz/src/ou/vendor$ cd ../..
thinkerou@MacBook-Pro-thinkerou:~/xyz/src$ ls
github.com ou
thinkerou@MacBook-Pro-thinkerou:~/xyz/src$ cd github.com/
thinkerou@MacBook-Pro-thinkerou:~/xyz/src/github.com$ ls
zenazn
Run Code Online (Sandbox Code Playgroud)

vendor.json 这是:

{
    "comment": "",
    "package": [
        {
            "path": "github.com/zenazn/goji"
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

那么,我应该使用什么命令?为什么没用vendor?我的版本是1.6.2.

go vendor

32
推荐指数
1
解决办法
3万
查看次数

如何使用gtest测试带有多个模板参数的c ++模板类?

我想用gtest测试模板类.我TYPED_TEST在gtest手册中读到了s,并查看了他们引用的官方示例(samples\sample6_unittest.cc).示例中的此模板只有一个模板参数.但是,我的代码有两个模板参数,我该如何测试呢?

我有以下代码:

// two element type
template <typename E, typename F>
class QueueNew
{
public:
    QueueNew() {}
    void Enqueue(const E& element) {}
    E* Dequeue() {}
    F size() const 
    {
        return (F)123;
    }
};
Run Code Online (Sandbox Code Playgroud)

我为此编写了下面的测试代码:

template <class E, class F>
QueueNew<E, F>* CreateQueue();

template <>
QueueNew<int, int>* CreateQueue<int, int>()
{
    return new QueueNew < int, int > ;
}
template <>
QueueNew<char, char>* CreateQueue<char, char>()
{
    return new QueueNew < char, char > ;
}

template <class …
Run Code Online (Sandbox Code Playgroud)

c++ templates googletest

8
推荐指数
2
解决办法
5036
查看次数

使用 GCC 编译选项“-Werror”时如何忽略错误?

我有以下测试代码,文件test.c

#include <stdio.h>

int *func()
{
    int i = 123;
    return &i;
}

int main()
{
    printf("%d\n", *func());
}
Run Code Online (Sandbox Code Playgroud)

如果我使用命令来编译它就可以了,

#include <stdio.h>

int *func()
{
    int i = 123;
    return &i;
}

int main()
{
    printf("%d\n", *func());
}
Run Code Online (Sandbox Code Playgroud)

它将有以下警告信息:

gcc test.c -o test
Run Code Online (Sandbox Code Playgroud)

但可以输出结果:123

如果我使用命令:

warning: address of stack memory associated with local variable 'i'
  returned [-Wreturn-stack-address]
return &i;
        ^
1 warning generated.
Run Code Online (Sandbox Code Playgroud)

将会有如下错误信息:

gcc -Werror test.c -o test
Run Code Online (Sandbox Code Playgroud)

现在我想使用-Werror选项,但我也想忽略与局部变量“i”警告关联的堆栈内存的地址。我应该怎么办?

c clang

5
推荐指数
1
解决办法
1万
查看次数

如何将列表保存到Spark中?

我已经阅读了这篇SO帖子,但是我仍然需要随机。

我有数据集,如下所示:

123456789
23458ef12
ef12345ea
111223345
Run Code Online (Sandbox Code Playgroud)

我想从中得到一些朗姆线,因此我编写了以下pyspark代码:

rdd = spark_context.textFile('a.tx').takeSample(False, 3)
rdd.saveAsTextFile('b.tx')
Run Code Online (Sandbox Code Playgroud)

所以takeSample返回列表,它将出现一个错误:

'list' object has no attribute 'saveAsTextFile'
Run Code Online (Sandbox Code Playgroud)

python apache-spark pyspark

5
推荐指数
1
解决办法
5702
查看次数

如何解决python请求错误:“Max retries exceeded with url”

我有以下代码:

res = requests.get(url)
Run Code Online (Sandbox Code Playgroud)

我使用多线程方法会出现以下错误:

ConnectionError: HTTPConnectionPool(host='bjtest.com', port=80): Max retries exceeded with url: /rest/data?method=check&test=123 (Caused by: [Errno 104] Connection reset by peer)

我已经使用了follow方法,但它仍然有错误:

s = requests.session()
s.keep_alive = False
Run Code Online (Sandbox Code Playgroud)

或者

res = requests.get(url, headers={'Connection': 'close'})
Run Code Online (Sandbox Code Playgroud)

那么,我应该怎么办呢?

顺便说一句,url没关系,但它只能在内部访问,所以url没有问题。谢谢!

python python-requests

5
推荐指数
2
解决办法
2万
查看次数

如何使用 psycopg2 获取 PostgreSQL 版本?

我有以下声明:

from alembic import op
conn = op.get_bind()
Run Code Online (Sandbox Code Playgroud)

现在我想获得 postgresql 版本。

postgresql psycopg2

4
推荐指数
1
解决办法
3991
查看次数

(= [:a:b](list:a:b))在clojure中返回true?

在Clojure中,(= [:a :b] (list :a :b))返回true,但(= [:a :b] (:a :b))返回false.为什么?

我想(list :a :b)是的(:a :b),所以都不应该回归true.

clojure

2
推荐指数
1
解决办法
304
查看次数