登录
首页 >  Golang >  Go问答

修改后输出:后处理失败:820:39:参数列表缺少逗号

来源:stackoverflow

时间:2024-02-19 11:54:24 494浏览 收藏

哈喽!大家好,很高兴又见面了,我是golang学习网的一名作者,今天由我给大家带来一篇《修改后输出:后处理失败:820:39:参数列表缺少逗号》,本文主要会讲到等等知识点,希望大家一起学习进步,也欢迎大家关注、点赞、收藏、转发! 下面就一起来看看吧!

问题内容

protoc-gen-validate 是一个协议插件,用于生成多语言消息验证器。

该项目使用 bazel 进行构建,并有一个开放的拉取请求来添加对验证错误消息自定义的支持。

原始代码是2020年制作的。最近更新了最新代码,修复了所有合并冲突后,现在无法构建,但我找不到问题:

~/github/protoc-gen-validate (i18n) $ make bazel-tests
bazel test //tests/... --test_output=errors
info: analyzed 68 targets (0 packages loaded, 0 targets configured).
info: found 62 targets and 6 test targets...
error: /users/mparnisari/github/protoc-gen-validate/tests/harness/cases/build:46:21: generating into bazel-out/darwin-fastbuild/bin/tests/harness/cases/go_/github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go failed: (exit 1): go-protoc-bin failed: error executing command bazel-out/darwin-opt-exec-2b5cbbc6/bin/external/io_bazel_rules_go/go/tools/builders/go-protoc-bin_/go-protoc-bin -protoc bazel-out/darwin-opt-exec-2b5cbbc6/bin/external/com_google_protobuf/protoc ... (remaining 117 argument(s) skipped)

use --sandbox_debug to see verbose messages from the sandbox
[error] failed post-processing: 820:39: missing ',' in argument list (and 10 more errors)
--validate_out: protoc-gen-validate: plugin failed with status code 1.
2021/12/14 23:46:43 error running protoc: exit status 1
error: /users/mparnisari/github/protoc-gen-validate/tests/harness/cases/build:46:21 gocompilepkg tests/harness/cases/go.a failed: (exit 1): go-protoc-bin failed: error executing command bazel-out/darwin-opt-exec-2b5cbbc6/bin/external/io_bazel_rules_go/go/tools/builders/go-protoc-bin_/go-protoc-bin -protoc bazel-out/darwin-opt-exec-2b5cbbc6/bin/external/com_google_protobuf/protoc ... (remaining 117 argument(s) skipped)

use --sandbox_debug to see verbose messages from the sandbox
info: elapsed time: 0.962s, critical path: 0.48s
info: 8 processes: 8 internal.
failed: build did not complete successfully

根据以下事实判断,在我触发测试命令后立即出现错误 ([error] failed post-processing: 820:39: missing ',' in argument list (and 10 more error)),我想这是 bazel 的问题,但我不确定。

更新 1:我将范围缩小到:

~/GitHub/fork/protoc-gen-validate (i18n) $ make testcases
cd tests/harness/cases && \
        protoc \
                -I . \
                -I ../../.. \
                --go_out="module=github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go,Mtests/harness/cases/other_package/embed.proto=github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/other_package/go;other_package,Mtests/harness/cases/yet_another_package/embed.proto=github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/yet_another_package/go,Mvalidate/validate.proto=github.com/envoyproxy/protoc-gen-validate/validate,Mgoogle/protobuf/any.proto=google.golang.org/protobuf/types/known/anypb,Mgoogle/protobuf/duration.proto=google.golang.org/protobuf/types/known/durationpb,Mgoogle/protobuf/struct.proto=google.golang.org/protobuf/types/known/structpb,Mgoogle/protobuf/timestamp.proto=google.golang.org/protobuf/types/known/timestamppb,Mgoogle/protobuf/wrappers.proto=google.golang.org/protobuf/types/known/wrapperspb,Mgoogle/protobuf/descriptor.proto=google.golang.org/protobuf/types/descriptorpb:./go" \
                --plugin=protoc-gen-go=/Users/mparnisari/go/bin/protoc-gen-go \
                --validate_out="module=github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/go,lang=go,Mtests/harness/cases/other_package/embed.proto=github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/other_package/go,Mtests/harness/cases/yet_another_package/embed.proto=github.com/envoyproxy/protoc-gen-validate/tests/harness/cases/yet_another_package/go:./go" \
                ./*.proto
filename-with-dash.proto:5:1: warning: Import validate/validate.proto is unused.
[error] failed post-processing: 820:39: missing ',' in argument list (and 10 more errors)
--validate_out: protoc-gen-validate: Plugin failed with status code 1.
make: 
*** [testcases] Error 1

更新2:缩小范围。如果我删除这个文件:tests/harness/cases/maps.proto

make 测试用例 有效

更新3:缩小范围。如果我删除这些行:https://github.com/envoyproxy/protoc-gen-validate/blob/main/tests/harness/cases/maps.proto#l14-l17

make testcase 有效


正确答案


使用开关 --sandbox_debug 进行构建将提供未截断的堆栈跟踪。
这都是因为缺少一个逗号……唯一的问题是在哪个文件和行中。

它抱怨 harness_py_proto 测试 @ 46:21。建议对文件 tests/harness/executor/cases.go 运行语法检查,因为如果 820:39 不在某些生成的文件中,则这可能是最适合的文件(按行号和错误消息)。我对 go 语法不太熟悉,这就是为什么我无法一眼发现它 - 但语法检查器或 linter 可以:

lint bazel testcases bazel-tests

makefile 也可能是一个可能的候选者,但没有太多进展:

.phony: harness
harness: testcases tests/harness/go/harness.pb.go tests/harness/go/main/go-harness tests/harness/cc/cc-harness bin/harness ## runs the test harness, validating a series of test cases in all supported languages
    ./bin/harness -go -cc

.phony: bazel-tests
bazel-tests: ## runs all tests with bazel
    bazel test //tests/... --test_output=errors

以前是否尝试过运行 makeharness?当它按照评论所说的那样时......

## runs the test harness, validating a series of test cases in all supported languages

今天关于《修改后输出:后处理失败:820:39:参数列表缺少逗号》的内容介绍就到此结束,如果有什么疑问或者建议,可以在golang学习网公众号下多多回复交流;文中若有不正之处,也希望回复留言以告知!

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>