小编Jon*_*nyD的帖子

在没有解释的情况下在 Goland 下划线

Goland 在 err 变量中显示下划线,但没有解释下划线原因的原因/没有工具提示(见下图——箭头指向奇怪的下划线)。 Goland 中的代码,带有 err 下划线

有谁知道下划线的原因?

(这似乎不是因为 err 是在上面几行定义的,因为我在其他文件中也有类似的 err 重用,并且它们中没有下划线)。

这是代码,尽管如果没有来自 IDE 的解释图片,这个问题将毫无意义,因为这似乎是 Goland 中的一个错误。

package mypack

import (
    "fmt"
    "os"
)

func SomeFunc() (string, error) {
    err := GetSomething()
    if err != nil {
        return "", fmt.Errorf("some err")
    }

    currentDirectory, err := os.Getwd()
    if err != nil {
        return "", fmt.Errorf("error getting current dir. %v", err)
    }

    return currentDirectory, nil
}

func GetSomething() error {
    return nil
}
Run Code Online (Sandbox Code Playgroud)

go goland

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

Elasticsearch Rest Client - 调用 performRequestAsync 时的 ConnectionClosedException

我在 HttpAsyncRequestExecutor 上遇到了问题。

我正在使用elasticsearch Java Rest ClientConnectionClosedException当我调用时总是得到一个(见下文)performRequestAsync

    // variables (all with valid format):
    // endpoint is just a List<String> with "14655/_search"

    // params is just a Map<String, String> with
    //   "pretty", "true"
    //   "search_type", "query_then_fetch"

    // entity is just a HttpEntity entity with the Json body request

    final int numRequests = endpoints.size();
    final CountDownLatch latch = new CountDownLatch(numRequests);
    try (Timer.Context ctx = this.requestTimer.time()) {
        for (final String endpoint : endpoints) {
            // ERROR hapens …
Run Code Online (Sandbox Code Playgroud)

java apache nio http elasticsearch

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

Terraform - 所需字符串列表(AWS 中的 cidr_blocks)

在 Terraform 中,我在输入将存储在变量中的列表时遇到问题。

在执行时terraform plan,我被要求提供 cidr_blocks (它应该是字符串列表)。

我尝试输入几个可能代表字符串列表的“表单”,但总是出现错误。

例子:

第一次尝试:

$terraform plan
...
var.monitoring_access_ips_mysystem
  Enter a value: "10.180.1.0/24", "10.180.2.0/25", "10.180.3.0/23"
Run Code Online (Sandbox Code Playgroud)

第二次尝试:

var.monitoring_access_ips_mysystem
  Enter a value: ["10.180.1.0/24", "10.180.2.0/25", "10.180.3.0/23"]
Run Code Online (Sandbox Code Playgroud)

第三次尝试:

var.monitoring_access_ips_mysystem
  Enter a value: '["10.180.1.0/24", "10.180.2.0/25", "10.180.3.0/23"]'
Run Code Online (Sandbox Code Playgroud)

第四次尝试:

var.monitoring_access_ips_mysystem
  Enter a value: "["10.180.1.0/24", "10.180.2.0/25", "10.180.3.0/23"]"
Run Code Online (Sandbox Code Playgroud)

第五次尝试:

var.monitoring_access_ips_mysystem
  Enter a value: "10.180.1.0/24"
Run Code Online (Sandbox Code Playgroud)

对于任何尝试,错误总是相同的:

Error: Incorrect attribute value type

  on ecs/security_group.tf line 10, in resource "aws_security_group" "ecs-cluster-sg":
  10:     cidr_blocks = var.monitoring_access_ips_mysystem

Inappropriate value for attribute "cidr_blocks": list of string required.
Run Code Online (Sandbox Code Playgroud)

该 …

amazon-web-services iaas aws-cloudformation terraform

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

Guava Joiner 对 null 元素抛出 NPE

Joiner这里初始化不正确吗?我有以下课程,当我尝试使用 加入示例paths数组时joiner,我得到了一个NullPointerException.

public class CPath {
  private static final Joiner joiner = Joiner.on("/");

  private String[] elements;

  @Override
  public String toString() {
    return joiner.join(elements);
  }
}

// main method
final String[] paths = {"a/b/c", "d", "", null, "e/f/g", "h/i", null, ""};
final CPath c3 = new CPath(paths);
c3.toString(); //<<<< NPE
Run Code Online (Sandbox Code Playgroud)

java guava

0
推荐指数
1
解决办法
1565
查看次数