电话中没有足够的参数

时间:2015-05-15 21:09:35

标签: go

我正在尝试创建一个显示用户IP的应用程序。

我无法弄清楚我的日志控制台错误:

  

go:14:调用getJsonRes时没有足够的参数

转到应用代码:

import java.io.*;

class chefAndNewRecipe 
{
public static void main(String[] args) throws IOException
{
    // TODO Auto-generated method stub
    BufferedReader r = new BufferedReader(new FileReader("/home/jer/Documents/chef.txt"));
    int testCases = Integer.parseInt(r.readLine());
    int numGuesses =0 ;

    for (int i=0; i<testCases; i++)
    {
        int ingredients = Integer.parseInt(r.readLine());

        String quantity = r.readLine();
        String arr[] = quantity.split(" ");
        int[] numIngredients = new int[arr.length];

        for (int j =0; j< ingredients; j++)
        {
            String temp = arr[i];
            numIngredients[i] = Integer.parseInt(temp);
            System.out.println("This is numIngredients index: " + j + " and value " +numIngredients[i]);//print array location and value
        }
        System.out.println("numIngredients[0]:" + numIngredients[0]); // should be 2 and is
        System.out.println("numIngredients[1]:" + numIngredients[1]); // should be 2 and is 0??
        for (int k = 0; k< numIngredients.length; k++)
        {   
            if (numIngredients[k] <2)
            {   
                System.out.println("Value of numIngredients[k]: " + numIngredients[k]);// print value of numIngredients
                System.out.println("-1");
            }
            else
            {   
                numGuesses += numIngredients[k];
            }

        }   
            System.out.println(numGuesses);
    }
}
}

1 个答案:

答案 0 :(得分:3)

你的功能

func getJsonRes(r *http.Request)([]byte, error )

接受请求指针并返回字节数组或错误。

在这一行

response, err := getJsonRes()

你在没有参数的情况下调用它。您可能打算执行以下操作

response, err := getJsonRes(r)