将Caddy导入go项目中的依赖项失败

罗密欧·米哈尔恰(Romeo Mihalcea):

我想导入Caddy一个go项目,但是即使是最基本的示例,我似乎也无法提出。我尝试通过depgo mod失败都导致依赖关系失败。

dep init

No versions of golang.org/x/text met constraints:
    v0.3.0: unable to update checked out version: : command failed: [git checkout f21a4dfb5e38f5895301dc265a8def02365cc3d0]: exit status 128
    v0.2.0: unable to update checked out version: : command failed: [git checkout c4d099d611ac3ded35360abf03581e13d91c828f]: exit status 128
    v0.1.0: unable to update checked out version: : command failed: [git checkout ab5ac5f9a8deb4855a60fab02bc61a4ec770bd49]: exit status 1
    master: unable to update checked out version: : command failed: [git checkout fe223c5a2583471b2791ca99e716c65b4a76117e]: exit status 1
    release-branch.go1.11: unable to update checked out version: : command failed: [git checkout cb6730876b985e110843c1842a7a63a63677cf08]: exit status 1
    release-branch.go1.12: unable to update checked out version: : command failed: [git checkout e6919f6577db79269a6443b9dc46d18f2238fb5d]: exit status 1

go build (使用go mod)

go build
go: finding github.com/mholt/caddy/caddyhttp latest
go: finding github.com/jimstudt/http-authentication/basic latest
go: finding github.com/jimstudt/http-authentication latest
go: finding github.com/mholt/certmagic latest
go: finding github.com/flynn/go-shlex latest
go: finding github.com/lucas-clemente/quic-go/h2quic latest
go: finding golang.org/x/net/http2 latest
go: finding golang.org/x/net latest
go: finding github.com/xenolf/lego/certcrypto latest
go: finding github.com/xenolf/lego/challenge latest
go: finding github.com/xenolf/lego/challenge/tlsalpn01 latest
go: finding github.com/lucas-clemente/quic-go-certificates latest
go: finding github.com/cheekybits/genny/generic latest
go: finding github.com/lucas-clemente/aes12 latest
go: finding github.com/bifurcation/mint latest
# github.com/mholt/caddy/caddyhttp/markdown/summary
/home/ciokan/go/pkg/mod/github.com/mholt/[email protected]/caddyhttp/markdown/summary/render.go:24:5: cannot use (*renderer)(nil) (type *renderer) as type blackfriday.Renderer in assignment:
    *renderer does not implement blackfriday.Renderer (missing RenderFooter method)
/home/ciokan/go/pkg/mod/github.com/mholt/[email protected]/caddyhttp/markdown/summary/summary.go:26:44: too many arguments to conversion to blackfriday.Markdown: blackfriday.Markdown(input, renderer literal, 0)
# github.com/lucas-clemente/quic-go/internal/crypto
/home/ciokan/go/pkg/mod/github.com/lucas-clemente/[email protected]/internal/crypto/key_derivation.go:46:37: cs.KeyLen undefined (type mint.CipherSuiteParams has no field or method KeyLen)
/home/ciokan/go/pkg/mod/github.com/lucas-clemente/[email protected]/internal/crypto/key_derivation.go:47:35: cs.IvLen undefined (type mint.CipherSuiteParams has no field or method IvLen)
# github.com/mholt/caddy/caddytls
/home/ciokan/go/pkg/mod/github.com/mholt/[email protected]/caddytls/setup.go:174:28: cannot use value (type "github.com/xenolf/lego/certcrypto".KeyType) as type "github.com/go-acme/lego/certcrypto".KeyType in assignment
/home/ciokan/go/pkg/mod/github.com/mholt/[email protected]/caddytls/setup.go:354:4: cannot use config.Manager.KeyType (type "github.com/go-acme/lego/certcrypto".KeyType) as type "github.com/xenolf/lego/certcrypto".KeyType in field value

这是一个非常基本的脚本:

package main

import (
        "fmt"
        "io/ioutil"
        "os"

        "github.com/mholt/caddy"
        _ "github.com/mholt/caddy/caddyhttp"
)

func init() {
        caddy.SetDefaultCaddyfileLoader("default", caddy.LoaderFunc(loadConfig))
}

func loadConfig(serverType string) (caddy.Input, error) {
        contents, err := ioutil.ReadFile(caddy.DefaultConfigFile)
        if err != nil {
                if os.IsNotExist(err) {
                        return nil, nil
                }
                return nil, err
        }
        fmt.Printf("Loading Caddyfile: %s\n", string(contents))
        return caddy.CaddyfileInput{
                Contents:       contents,
                Filepath:       caddy.DefaultConfigFile,
                ServerTypeName: serverType,
        }, nil
}

func main() {
        caddy.AppName = "MyApp"
        caddy.AppVersion = "0.1"

        caddyfile, err := caddy.LoadCaddyfile("http")
        if err != nil {
                panic(err)
        }

        inst, err := caddy.Start(caddyfile)
        if err != nil {
                panic(err)
        }
        inst.Wait()
}

那么我应该如何在自己的包装中使用Caddy?

斯特凡·让·多(StéphaneJeandeaux):

您可以尝试以下一种方法吗?

module stack/cady

go 1.12

require (
    github.com/bifurcation/mint v0.0.0-20180715133206-93c51c6ce115 // indirect
    github.com/cenkalti/backoff v2.1.1+incompatible // indirect
    github.com/cheekybits/genny v1.0.0 // indirect
    github.com/dustin/go-humanize v1.0.0 // indirect
    github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect
    github.com/google/uuid v1.1.1 // indirect
    github.com/gorilla/websocket v1.4.0 // indirect
    github.com/hashicorp/go-syslog v1.0.0 // indirect
    github.com/hashicorp/golang-lru v0.5.1 // indirect
    github.com/jimstudt/http-authentication v0.0.0-20140401203705-3eca13d6893a // indirect
    github.com/lucas-clemente/aes12 v0.0.0-20171027163421-cd47fb39b79f // indirect
    github.com/lucas-clemente/quic-go v0.10.1-no-integrationtests // indirect
    github.com/lucas-clemente/quic-go-certificates v0.0.0-20160823095156-d2f86524cced // indirect
    github.com/mholt/caddy v0.11.5
    github.com/mholt/certmagic v0.0.0-20190225061201-e3e89d1096d7 // indirect
    github.com/naoina/go-stringutil v0.1.0 // indirect
    github.com/naoina/toml v0.1.1 // indirect
    github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4 // indirect
    github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
    github.com/xenolf/lego v2.2.1-0.20190304181753-67b329e3e370+incompatible // indirect
    golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53 // indirect
    gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
    gopkg.in/yaml.v2 v2.2.2 // indirect
)

可能不是最好的解决方案,但我做了什么:

  1. https://github.com/mholt/caddy/blob/v0.11.5/vendor/manifest中的供应商文件夹中阅读清单
  2. 获取有麻烦的进口件的修订版
  3. 修改需求部分中的版本

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将 Maven 依赖项导入 Java 项目

Intellij IDEA不在Groovy项目中从@Grab导入依赖项

将Maven项目添加为Maven项目中的依赖项

将Maven项目作为依赖项导入Gradle项目

无法将Mapper添加为Lift项目中的依赖项

在WebApi2项目中使用CacheOutput属性时,依赖项的解析失败

安装Go依赖项失败

如何在go dep项目中将go模块用作依赖项?

在jersey项目中包括jersey-bom导入作用域依赖项的目的是什么?

错误:我添加新依赖项时,项目中的任务':app:dexDebug'错误执行失败

在Maven项目中查找依赖项(反向依赖项)

在项目中本地安装Python依赖项

在堆栈项目中添加依赖项?

分析Java项目中的JAR依赖项

IntelliJ项目中的Maven依赖项

扫描CMake项目中的依赖项很慢

将多个项目本身添加为另一个项目中的依赖项

如何将gradle作为依赖项添加到子项目根项目中?

多个项目中的项目找不到特定的项目依赖项

将Spring for android依赖项添加到Gradle + Android Studio项目中

如何将com.typesafe.sbt。*依赖项添加到我的项目中?

如何使用Maven将Clojure依赖项包含到Java项目中

无法将JPA依赖项添加到spring-boot项目中

如何将scalatest依赖项添加到现有的scala / lift项目中?

将lombok依赖项添加到我的项目中时,TypeNotPresentExceptionProxy

如何将依赖项注入.Net Core项目中的自定义WebHostService中?

如何将Geoscript作为依赖项包含在Scala智能项目中?

无法将Gradle依赖项添加到我的代号一个项目中

将commons-io依赖项添加到Android Studio中的gradle项目中