不器小窝 不器小窝
首页
随笔
  • GoLang
  • 前端

    • Vue
    • VuePress
  • 开发工具
  • 系统工具
读吧
  • ToDb (opens new window)
  • goKit (opens new window)
  • 友情链接
  • 免费信息
  • 时间线
  • 关于
GitHub (opens new window)

不器

知行合一
首页
随笔
  • GoLang
  • 前端

    • Vue
    • VuePress
  • 开发工具
  • 系统工具
读吧
  • ToDb (opens new window)
  • goKit (opens new window)
  • 友情链接
  • 免费信息
  • 时间线
  • 关于
GitHub (opens new window)
  • GoLang

    • GoLang 安装
    • Go经验
    • 错误集合
      • 前言
      • conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)
      • missing dot in first path element问题解决
        • 问题原因
    • 基础库

    • 第三方库

    • Fyne

    • Wails

    • GoFrame

  • Dart

  • Markdown

  • 语言
  • GoLang
不器
2023-02-13
目录

错误集合

# 前言

使用GoLang中遇到的奇葩问题,本文持续更新

# conversion from int to string yields a string of one rune, not a string of digits (did you mean fmt.Sprint(x)?)

翻译:

从int到字符串的转换产生一个符文字符串,而不是一个数字字符串(你是指fmt.Sprint(x)吗?)

解决方案:

// 产生错误的写法,会导致编译不通过
func Day() string {
	return string(time.Now().Day())
}

// 正确的写法
func Day() string {
	return fmt.Sprintf("%v", time.Now().Day())
}
1
2
3
4
5
6
7
8
9

# missing dot in first path element问题解决

我出现这个原因是使用开源代码的时候将原始的引用改变了但是忘记改变go.mod中的嵌套引用了。

# 问题原因

因为在go1.13中,go module名称规范要求路径的第一部分必须满足域名规范,否则可能汇报类似

malformed module path "xxxx": missing dot in first path element这样的错误。

#GoLang错误#Go错误
更新时间: 2023/3/2 16:25:21
Go经验
flag

← Go经验 flag→

最近更新
01
Vue-pure-Admin基础
03-16
02
WebStorm工具使用手册
03-15
03
Windows
03-12
更多文章>
Theme by Vdoing | Copyright © 2022-2023 不器 | 小窝
sitemap icon by Icons8
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式