如何管理多次使用的Nuget包(How to manage Nuget Packages used more than once)
我是一个恐龙开发者,所以NuGet对我来说比较新,我习惯于管理第三方开源库,只有一个项目包含代码或二进制文件,我会在必要时不断更新,这个项目发布了dll(s )在一个公共文件夹上,我在所有项目中引用库。 这样可以很容易地维护第三方库,在我的项目中,我只需要在更新库时重建,一切顺利。 现在很多开源项目都在NuGet上发布它们的库,很容易在项目中引用它们,但我担心我必须为我使用它的每个项目下载一个库的副本,在我看来是可以导致混乱的东西。 特别是如果我有两个构建dll的项目最终使用相同软件包的2个不同版本,并且在具有问题和冲突的应用程序中使用。 所以我对那些长时间使用NuGet的人的问题是:我可以像其他库一样继续使用NuGet包并创建一个引用它们的项目,使用它在单个文件夹中发布dll然后引用包的dll从我的dll和已发布文件夹上的应用程序。
我希望我已经清楚了。 感谢您对Sabrina这个话题的任何想法
I am a dinosaur developer, so NuGet is relatively new to me, I am used to manage third parties open source libraries having a single project with the code or the binaries, that I will keep updated when necessary and this project publishes the dll(s) on a common folder from where I reference the libraries in all my projects. This makes easy to maintain the third party libraries and in my projects I just need to rebuild when I update the library and all goes OK. Now many open source projects publish their libraries on NuGet and it is easy to reference them in the projects, but I dread the fact that I have to download a copy of the library for each project in which I use it, this, in my opinion is something that can lead to chaos. Especially if I have 2 projects that build dlls that end up using 2 different versions of the same packages and are used both in an application with problems and conflicts. So my question to those who use NuGet from a longer time is: Can I proceed with NuGet packages as with other libraries and create a project that references them, use it to publish the dlls in a single folder and then reference the dlls of the packages from my dlls and applications on the published folder.
I hope I've been clear. Thanks for any thoughts you can share on this topic Sabrina
原文:https://stackoverflow.com/questions/40504047
最满意答案
好,我知道了:
var myData [][]interface{} = make([][]interface{}, len(resp[0].Series[0].Values)) for i, d := range resp[0].Series[0].Values { myData[i] = d } fmt.Println("", myData[0]) //first element in slice fmt.Println("", myData[0][0]) fmt.Println("", myData[0][1])
输出:
[2016-10-24T00:12:12.123456Z 192.168.123.107] 2016-10-24T00:12:12.123456Z 192.168.123.107
Ok, I got it:
var myData [][]interface{} = make([][]interface{}, len(resp[0].Series[0].Values)) for i, d := range resp[0].Series[0].Values { myData[i] = d } fmt.Println("", myData[0]) //first element in slice fmt.Println("", myData[0][0]) fmt.Println("", myData[0][1])
output:
[2016-10-24T00:12:12.123456Z 192.168.123.107] 2016-10-24T00:12:12.123456Z 192.168.123.107
相关问答
更多-
首先,我必须说:首先是配置文件。 这真的是你的代码中的瓶颈吗? 如果是这样,你有几个选择。 1)禁用边界检查。 我认为有一个没有记录的编译器标志可以检测切片边界。 尽管目前我找不到它。 (编辑: -B根据OP)。 2)用C语言(或汇编语言)编写例程,你可以为[586] c写入C并链接到你的包中(你需要包含一些来自$GOROOT/src/pkg/runtime头文件),如下所示: #include "runtime.h" mypackage·swapslice(Slice s) { int i, j; ...
-
要确保Go不将基础字符串保留在内存中,您必须将其显式复制到新位置: func unslice(old string) string { new := make([]byte,len(old)) copy(new,old) return string(old) } SmallString := unslice(BigString[0:7]) To ensure that Go doesn't keep the underlying string in memory you will ...
-
对你有用的不是类型断言 - 它是操作顺序。 问题的根源在于索引在指针解除引用之前。 一旦你在指针解除引用周围放置大括号,它一切正常,因为索引应用于现在解除引用的PriorityQueue实例。 您不需要为数组指针执行此操作,因为它们会自动解除引用 - 索引数组和切片之间的细微差别在此解释: Go编程语言规范 - 索引表达式 对于阵列类型A : 常量索引必须在范围内 如果x在运行时超出范围,则会发生运行时混乱 a[x]是索引x处的数组元素,而a[x]的类型是A的元素类型 对于指向数组类型的指针: a[x]是( ...
-
这样做并不是一种“更好”的方式。 要转换切片,您必须基本上执行您已经发现的切片。 如果您只是将这些错误返回给客户端,则可能完全无需对此进行类型转换。 实现JSON Marshaler接口,您可以使您的类型自动以您希望的格式输出JSON。 例如,对于上面给出的格式,这将是: func (e BadField) MarshalJSON() ([]byte, error) { return json.Marshal([]string{"field_name",e.Field,e.Err.Error()}) ...
-
我找到了临时解决方案 图书馆golang.org/x/crypto/bcrypt在github上有镜像。 在你的GOPATH创建文件夹src/golang.org/x/ 。 mkdir -p $GOPATH/src/golang.org/x/ 然后从github克隆加密 。 cd $GOPATH/src/golang.org/x/ git clone git@github.com:golang/crypto.git I found temporary solution. Library golang.o ...
-
看到这里: http : //blog.golang.org/slices 简短的答案:1)它增长倍增(虽然短)。 如果你追加一次,你可能会再次追加,这会避免分配。 2)这就是切片生长的原理。 一个数组不能增长,所以分配一个新的,更大的数组,旧的数组被复制,并且你交给一个指向较大副本的切片。 (golang.org网站上的文档非常有帮助,可读性强,简短而精确。我想建议先查看golang.org,然后再问这里。) See here: http://blog.golang.org/slices Short an ...
-
http://golang.org/pkg/fmt/ fmt.Printf("address of slice %p add of Arr %p \n", &slice, &intarr) %p将打印地址。 http://golang.org/pkg/fmt/ fmt.Printf("address of slice %p add of Arr %p \n", &slice, &intarr) %p will print the address.
-
好,我知道了: var myData [][]interface{} = make([][]interface{}, len(resp[0].Series[0].Values)) for i, d := range resp[0].Series[0].Values { myData[i] = d } fmt.Println("", myData[0]) //first element in slice fmt.Println( ...
-
在范围声明中 for _, f := range fixtures { ... } f是一个新声明的Fixture类局部变量。 它不是任何参考 。 因此,在设置其值之后,必须将其放入fixtures片中。 package main import "fmt" type Fixture struct { Probabilities *[]float64 } func main() { fixtures := []Fixture{} f := Fixture ...
-
golang中切片的地址(Address of slice in golang)[2022-01-21]
这就是fmt.Println的定义。 来自https://golang.org/pkg/fmt/#Println : Println格式使用其操作数的默认格式并写入标准输出。 始终在操作数之间添加空格,并附加换行符。 它返回写入的字节数和遇到的任何写入错误。 在该页面的早期,描述默认格式: 对于复合对象,使用这些规则打印元素,递归地,如下所示: struct: {field0 field1 ...} array, slice: [elem0 elem1 ...] maps ...