go - Leekchan Accounting 与 ShopSpring Decimal 冲突

标签 go

我正在 https://github.com/leekchan/accounting 试用示例

package main

import (
    "fmt"
    "math/big"
    "github.com/shopspring/decimal"
    "github.com/leekchan/accounting"
)

func main() {
    ac := accounting.Accounting{Symbol: "$", Precision: 2}
    fmt.Println(ac.FormatMoney(123456789.213123))
}

并完全按照 Github 上显示的方式使用它们,我收到以下错误:

Failed parsing input: package "github.com/shopspring/decimal" is imported from multiple locations: "/users/dev/go/src/github.com/shopspring/decimal" and "/users/dev/go/src/github.com/leekchan/accounting/vendor/github.com/shopspring/decimal"

我不能遗漏:

github.com/shopspring/decimal

否则我会得到另一个错误。我试过:

"dec" github.com/shopspring/decimal

但这并没有改变任何东西。不应该吗?

奇怪的是我在任何地方都找不到有关此的任何详细信息。我真的是唯一得到这个的人吗,还是我遗漏了一些非常明显的东西?

最佳答案

这是因为他们有一个包含 github.com/shopspring/decimal 的 checkin vendor 目录,看起来您已经在您的路径中了。您最好在项目中有一个包含 github.com/shopspring/decimal 和 github.com/leekchan/accounting 的 vendor 目录,这样您的目录结构将如下所示:

- main.go
| - vendor
  | - github.com/leekchan/accounting
  | - github.com/shopspring/decimal

关于go - Leekchan Accounting 与 ShopSpring Decimal 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50259822/

相关文章:

time - 如何仅使用 time.After 编写我自己的 Sleep 函数?

插入和更新中的 Postgresql 死锁

go - 从 viper 配置文件中删除键值对

elasticsearch - 用于 Golang 的 Olivere 包中的 BulkIndexer 用于替换 Elastigo

golang iris直接返回模板html

google-app-engine - Google App Engine 高性能代理解决方法

go - 如何在 golearn 中使用经过训练的二进制文件

go - byte slice 操作

go - 文件上传到 s3 但不可见

go - 无法解析 Go 代码中的值