V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  qW7bo2FbzbC0  ›  全部回复第 13 页 / 共 80 页
回复总数  1599
1 ... 9  10  11  12  13  14  15  16  17  18 ... 80  
2024-08-01 11:31:49 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 如何在 go 移动文件?
如下语言内置库支持 move
https://docs.python.org/3/library/shutil.html
https://learn.microsoft.com/en-us/dotnet/api/system.io.file.move
https://docs.oracle.com/javase/tutorial/essential/io/move.html

如下语言不支持 move ,但是注释写的很明确
https://doc.rust-lang.org/std/fs/fn.rename.html
On Unix, if from is a directory, to must also be an (empty) directory. If from is not a directory, to must also be not a directory

这是 go 语言的注释
https://pkg.go.dev/os#Rename
Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. .....
2024-08-01 11:16:44 +08:00
回复了 qW7bo2FbzbC0 创建的主题 程序员 如何在 go 中移动文件
2024-08-01 10:42:07 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 如何在 go 移动文件?
@seth19960929 这个的确可以解决,用了这个方式,我就不需要用#替代.了
2024-08-01 10:30:44 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 如何在 go 移动文件?
@seth19960929 可是无论 mv a.conf a.bak 和 mv a.conf a.bak/ 在 unix 下都是相同的表现啊? mv a.conf a.bak 就是把文件移动到目录中
2024-08-01 09:56:45 +08:00
回复了 qW7bo2FbzbC0 创建的主题 程序员 如何在 go 中移动文件
2024-07-30 10:28:00 +08:00
回复了 Grocker 创建的主题 程序员 分辨多个用户之间是否是分身的算法?
你说的是否直接关联,在 neo4j 中就是一度关联,用关系长度进行过滤查询即可。
你说的取消关联,这个我不太理解,如果这两个是直接关联的话,那直接删除 p1 和 p2 的关系即可( delete relation 操作)
查询所有分身
Match (p1:Person)-[*]-(p2:Person)
WHERE p1.Name='张三'
RETURN p2

举个另外场景,查询与张三有性关系的人员(关系距离长度 100 以内),
Match (p1:Person)-[r:SEX*1...100]-(p2:Person)
WHERE p1.Name='张三'
RETURN p2
2024-07-30 10:21:16 +08:00
回复了 Grocker 创建的主题 程序员 分辨多个用户之间是否是分身的算法?
图数据库 neo4j 为例:

返回与张三最多两度关系内的关联人手机号

Match (p1:Person)-[*0..2]-(p2:Person)
WHERE p1.Name='张三'
Return Distinct p2.Telephone


可以去网上搜搜 neo4j 的案例深入了解下
2024-07-24 11:53:42 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
2024-07-18 11:03:59 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
@lambdaq 和强弱类型没有关系,驱动底层逻辑问题
2024-07-18 11:03:03 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
@all mysql driver 还有这个问题,int 正常,但是 string 还是 base64 encode 字符串,json.RawMessage 也不顶用。sqlite3 的驱动是正常的
2024-07-18 10:34:58 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
另外 sqlx 最新版本也修复了 map[string]interface{}返回 base64 encode 字符的问题
2024-07-17 18:28:36 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
@james122333 您是对的,这的确和 json.Marshal 没关系,是 go-mysql-driver 的问题。

https://github.com/go-sql-driver/mysql/pull/1424
2024-07-17 18:21:43 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
各位,我比对了下,[]interface{}没有被 json.Marshal 出正确的数值和类型,是与我用的 go-mysql-driver 版本有关。

1.6.0 版本是出现了与我预测不同的结果。1.8 版本出现了预测的结果

json.Marshal 可能与本次贴文无直接关系。

另外,我觉得问题出自 json.Marshal 是从这个 sof 链接中的评论得到的错误推论,的确有迷惑性( https://stackoverflow.com/questions/34089750/marshal-byte-to-json-giving-a-strange-string)


```
This is because some idiot Millennial at Google decided it. Breaking the behaviour the RFC their JSON impl claims to follow defines. Check stackoverflow.com/a/78662958/3768429 for details.
```

该文指出 json.Marshal 处理 uint8[]时,错误输出了文字, 验证代码如下
```
func main() {
var x = []uint8{1, 2, 3, 4, 5, 6}
var y = []int8{1, 2, 3, 4, 5, 6}
xBytes, err := json.Marshal(x)
if err != nil {
panic(err)
}
yBytes, err := json.Marshal(y)
if err != nil {
panic(err)
}
fmt.Println(fmt.Sprintf("uint8 %s, int8: %s", string(xBytes), string(yBytes)))
}
```
输出的结果为
```
uint8 "AQIDBAUG", int8: [1,2,3,4,5,6]
```

https://go.dev/play/p/KGNG6voRuDk
2024-07-17 17:02:16 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
@fregie 你满意就好
2024-07-17 16:02:43 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
按楼上说的 json.RawMessage 解决了,我没有想到要去 json 命名空间里找类型
@leonshaw
2024-07-17 15:41:07 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
@fregie 犯懒字面上是贬义词吧,你觉得不是攻击性的,那你可以自己多读几遍,不要替别人做决定。稳定不稳定不知道,写起来麻烦的代码后面维护起来肯定更麻烦
2024-07-17 15:30:06 +08:00
回复了 qW7bo2FbzbC0 创建的主题 Go 编程语言 被 go 语言的 json.Marshal 恶心到了
@lifei6671 1.8 之前还有什么办法避免 Interface 满天飞?
1 ... 9  10  11  12  13  14  15  16  17  18 ... 80  
关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2658 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 29ms · UTC 14:59 · PVG 22:59 · LAX 07:59 · JFK 10:59
♥ Do have faith in what you're doing.