天地维杰网

人如秋鸿来有信,事若春梦了无痕


  • 首页

  • Redis

  • java

  • linux

  • 日常问题

  • Spring和Springboot

  • Mac相关

  • 中间件

  • 架构

  • python

  • 前端

  • jvm

  • c语言

  • web3

  • 归档

  • 关于

  • 搜索
close

MAC VSCode Go代码第一次运行配置

时间: 2022-03-30   |   分类: mac     |   阅读: 212 字 ~1分钟

新建一个项目,创建main.go文件

package main

func main() {
	print("hello world ")
}

右键->Run Code,运行该文件,提示如下

[Running] cd "/Users/domino/VscodeGoProjects/go-redis-server-test/server/" && go run .
go: cannot find main module, but found .git/config in /Users/jiangwujie/VscodeGoProjects/go-redis-server-test
	to create a module there, run:
	cd .. && go mod init

在当前文件目录的shell中执行以下命令

go mod init main
domino@localhost server % go mod init main
go: creating new go.mod: module main

然后go代码就能正常使用vscode的Run Code运行了。

如果在其他目录新建go文件,但是引用同目录下的其他文件,有报undeclared name : Xxx compile 的这样的问题,也可以通过这种方式进行解决。

#mac# #vscode# #go#
Mac VMWARE 安装redis
CacheCloud安装部署与群集创建流程测试
  • 文章目录
  • 站点概览
不与天斗Domino

不与天斗Domino

Programmer & Architect

183 日志
15 分类
224 标签
© 2013 - 2023 天地维杰网 京ICP备13019191号-1
Powered by - Hugo v0.63.2
Theme by - NexT
0%