traefik.go:执行失败,无法解析新的命令:未找到:xxx
来源:stackoverflow
时间:2024-02-10 12:09:22 209浏览 收藏
积累知识,胜过积蓄金银!毕竟在Golang开发的过程中,会遇到各种各样的问题,往往都是一些细节知识点还没有掌握好而导致的,因此基础知识点的积累是很重要的。下面本文《traefik.go:执行失败,无法解析新的命令:未找到:xxx》,就带大家讲解一下知识点,若是你对本文感兴趣,或者是想搞懂其中某个知识点,就请你继续往下看吧~
我正在尝试构建一个 traefik 插件并基于 https://github.com/traefik/plugindemo#local-mode 在本地模式下测试它
现在这个插件什么都不做,只是返回“hello”。
这是我的文件结构:
在traefik/plugins-local/src/github.com/hongbo-miao/traefik-plugin-disable-graphql-introspection
文件夹中,我有:
.traefik.yml
entrypoints: graphql-server-entrypoint: address: :9000 api: insecure: true dashboard: true providers: file: filename: dynamic_conf.yaml log: level: debug experimental: localplugins: traefik-plugin-disable-graphql-introspection: modulename: github.com/hongbo-miao/traefik-plugin-disable-graphql-introspection
go.mod
module github.com/hongbo-miao/traefik-plugin-disable-graphql-introspection go 1.17
main.go
package main import ( "context" "net/http" ) type config struct{} func createconfig() *config { return &config{} } type disablegraphqlintrospection struct { next http.handler name string } func new(ctx context.context, next http.handler, config *config, name string) (http.handler, error) { return &disablegraphqlintrospection{ next: next, name: name, }, nil } func (a *disablegraphqlintrospection) servehttp(rw http.responsewriter, req *http.request) { rw.write([]byte("hello")) }
在根文件夹中,我有
traefik.yaml
entrypoints: graphql-server-entrypoint: address: :9000 api: insecure: true dashboard: true providers: file: filename: dynamic_conf.yaml log: level: debug experimental: localplugins: traefik-plugin-disable-graphql-introspection: modulename: github.com/hongbo-miao/traefik-plugin-disable-graphql-introspection
dynamic_conf.yaml
http: routers: graphql-server-entrypoint: service: graphql-server-service entrypoints: - graphql-server-entrypoint rule: host(`localhost`) middlewares: - my-traefik-plugin-disable-graphql-introspection services: graphql-server-service: loadbalancer: servers: - url: http://localhost:5000/ middlewares: my-traefik-plugin-disable-graphql-introspection: plugin: traefik-plugin-disable-graphql-introspection: headers: foo: bar
我有一个 graphql 服务器运行在 http://localhost:5000
我希望它通过 taefik 并通过 http://localhost:9000 公开
但是,当我跑步时
traefik --configfile=traefik.yaml
在根文件夹中,我收到错误
traefik.go:79:命令 traefik 错误:无法评估新:1:28:未定义:traefik_plugin_disable_graphql_introspection 119
traefik 插件由嵌入式 go 解释器 yaegi 即时执行。
该错误似乎是八重木引发的,但是,我不知道如何调试。
任何指南将不胜感激!
正确答案
得到了 Tom Moulard 的答复,谢谢! https://github.com/traefik/plugindemo/issues/15#issuecomment-1123741949
您的错误意味着Yaegi找不到traefik_plugin_disable_graphql_introspection
包的New
函数。因此,您可以看出 Yaegi 找到了您的插件并加载了它,但找不到该包。要解决此问题,您需要将插件代码中的 package main
行更改为 package traefik_plugin_disable_graphql_introspection
。
在 main.go 文件中将 package main
更改为 package traefik_plugin_disable_graphql_introspection
后,它现在可以工作了!
终于介绍完啦!小伙伴们,这篇关于《traefik.go:执行失败,无法解析新的命令:未找到:xxx》的介绍应该让你收获多多了吧!欢迎大家收藏或分享给更多需要学习的朋友吧~golang学习网公众号也会发布Golang相关知识,快来关注吧!
-
502 收藏
-
502 收藏
-
501 收藏
-
501 收藏
-
501 收藏
-
139 收藏
-
204 收藏
-
325 收藏
-
477 收藏
-
486 收藏
-
439 收藏
-
357 收藏
-
352 收藏
-
101 收藏
-
440 收藏
-
212 收藏
-
143 收藏
-
- 前端进阶之JavaScript设计模式
- 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。
- 立即学习 542次学习
-
- GO语言核心编程课程
- 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。
- 立即学习 508次学习
-
- 简单聊聊mysql8与网络通信
- 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让
- 立即学习 497次学习
-
- JavaScript正则表达式基础与实战
- 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。
- 立即学习 487次学习
-
- 从零制作响应式网站—Grid布局
- 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。
- 立即学习 484次学习