Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/go/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何解析golang中gherkin datatable的struct中声明了int类型的列的空/null/nil值?_Go_Gherkin - Fatal编程技术网

如何解析golang中gherkin datatable的struct中声明了int类型的列的空/null/nil值?

如何解析golang中gherkin datatable的struct中声明了int类型的列的空/null/nil值?,go,gherkin,Go,Gherkin,我想把小黄瓜数据表的值转换成struct。在该结构中,我有一个声明了int-type的属性。如果gherkin数据表中没有数据,我应该如何填充值?在当前场景中,它抛出一个错误 这是功能文件 Feature: send request In order to be a rest tester I need to be able to make rest requests to server Scenario: GET request are allowed When I s

我想把小黄瓜数据表的值转换成struct。在该结构中,我有一个声明了int-type的属性。如果gherkin数据表中没有数据,我应该如何填充值?在当前场景中,它抛出一个错误

这是功能文件


Feature: send request
  In order to be a rest tester
  I need to be able to make rest requests to server

  Scenario: GET request are allowed
    When I send "GET" request to "http://localhost:3000/posts/"
    Then the response code should be 200
    And the response from server should match:
    | Id | Title | Author | Worth |
    | 1 | json-server | typicode |  |
以下是相应的结构:

type response struct {
    Id     int    `json:"id"`
    Title  string `json:"title"`
    Author string `json:"author"`
    Worth int `json:"worth"`
}
使用以下代码行将其转换为struct:

assist := assistdog.NewDefault()
expectedStruct := &response{}
result, err2 := assist.CreateSlice(expectedStruct, dataTable)
我在这个案子上犯了错误。谁能帮帮我吗?
提前感谢:)

您得到的错误是什么?我尝试了这个,但似乎assistdog不支持指针。你必须考虑使用一种不同的说法,但我看了源头。Assistdog绝对不支持int指针。以下是“错误:未能将表解析为*main.response:row 0:-监视:strconv.Atoi:parsing”“:无效语法”案例的错误