云端golang开发,无需本地配置,能上网就能开发和运行

欢迎访问我的GitHub

这里分类和汇总了欣宸的全部原创(含配套源码):github.com/zq2599/blog…

需求

  • 学习golang的时候,需要一个IDE,还需要一个能运行程序的环境,以及一个MySQL数据库
  • 对于有经验的程序员来说,自己动手安装部署即可,但是小白和懒人也是存在的…

背景

  • 背景很简单:欣宸个人情况如下
  1. 穷:有个能上网的破电脑,甚至电脑都没有,仅有个安卓平板(万幸的是有键盘鼠标,打字没问题)
  2. 懒:不想安装golang,也不想安装vscode(如果只有安卓平板,就是想装也没办法装)
  • 面对这样无可救药的自己,内心还是想拯救一下,于是有了这篇文章,基于GitHub的Codespaces 快速搭建一套云端开发环境,让穷、懒不再拖累我学习的热情…

前提

  • 用破电脑凭空打造golang开发环境,需要以下两个前提条件
  1. 能上网,因为要访问GitHub
  2. 有个属于自己的GitHub账号
  3. 免费使用的云端环境不是无限供应的,120核时每月,也就是说配置成4核的服务器,一个月能用30小时
  • 准备好以上条件就开始吧

打造环境

  • 首先登录GitHub
  • 其次准备好一个代码仓库,已有的或现在就新建都可以,我这里用的是旧仓库,里面保存了多年的博客中用到的源码,是个超级大杂烩,有java工程的,也有golang的,还有一些ansible脚本,如下所示,不过没事儿,不影响,都能用
    在这里插入图片描述
  • 然后按照下图的数字顺序进行操作,进入云端开发环境的设置页面
    在这里插入图片描述
  • 然后按照下图操作,选择配置模板
    在这里插入图片描述
  • 按照下图操作,获取到配置模板,然后粘贴到自己项目的配置区域,再提交保存,这样就完成了自己的golang云开发环境配置
    在这里插入图片描述
  • 注意上面的内容,共有两个配置项
  1. 部署了go1.18版本,您可以根据自己的需要修改,我这改成了1.19
  2. 安装了docker(配置里叫docker-in-docker,因为咱们的云开发环境就是个docker容器,官方文档中有说明)
  • 然后回到仓库主页面,按照如下操作,即可创建一个云开发环境,用的是前面的配置
    在这里插入图片描述
  • 然后需要等待几分钟,GitHub会根据您的配置创建新的云开发环境
  • 稍作等待就会跳转到web版本的vscode页面,如下图(安卓平板电脑浏览器截图),资源管理器的内容就是您的GitHub仓库的内容,由于我的仓库中有很多java旧代码,被vscode识别到之后会提示安装JDK,请无视掉这些提示,因为它们都和本篇无关
    请添加图片描述
  • 如下图,在控制台查看golang和docker的版本,都符合预期,微软真是给力,web版IDE和服务器都白送
    请添加图片描述
  • 用top命令查看资源情况,发现是2核4G的服务器资源
    请添加图片描述
  • 其实微软还算慷慨,免费资源最多给到了4核8G,咱们回到仓库页面去调整一下,如下图
    在这里插入图片描述
  • 如下图修改配置,并使其立即生效
    在这里插入图片描述
  • 至此,环境准备好了,咱们来写代码验证一下

设置GO111MODULE

  • 记得用go env看一下GO111MODULE环境变量的设置,因为接下来的项目是基于go mod进行管理的,所以要打开这个设置,最好是执行以下命令,使其生效
go env -w GO111MODULE=on
go env -w GO111MODULE=on
go env -w GO111MODULE=on

验证之一:helloworld

  • 接下来咱们基于gin新建一个web服务,试试这个开发环境能否正常使用
  • 在web版的vscode上,找个干净目录,例如我这边新建名为test003的文件夹
  • 用go mod命令新建module
go mod init test003
go mod init test003
go mod init test003
  • 下载和安装gin
go get -u github.com/gin-gonic/gin
go get -u github.com/gin-gonic/gin
go get -u github.com/gin-gonic/gin
  • 新建main.go文件,内容如下
package main
import "github.com/gin-gonic/gin"
func main() {
router := gin.Default()
router.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "hello world",
})
})
router.Run()
}
package main



import "github.com/gin-gonic/gin"

func main() {
  router := gin.Default()
  router.GET("/", func(c *gin.Context) {
    c.JSON(200, gin.H{
      "message": "hello world",
    })
  })
  router.Run()
}
package main import "github.com/gin-gonic/gin" func main() { router := gin.Default() router.GET("/", func(c *gin.Context) { c.JSON(200, gin.H{ "message": "hello world", }) }) router.Run() }
  • 执行go mod tidy解决依赖
  • 最后执行go run main.go将服务运行起来
@zq2599 ➜ /workspaces/blog_demos/tutorials/test003 (dev) $ go run main.go
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
- using env: export GIN_MODE=release
- using code: gin.SetMode(gin.ReleaseMode)
[GIN-debug] GET / --> main.main.func1 (3 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default
[GIN-debug] Listening and serving HTTP on :8080
[GIN] 2023/02/04 - 14:10:22 | 200 | 58.7µs | 220.246.254.226 | GET "/"
[GIN] 2023/02/04 - 14:10:22 | 404 | 900ns | 220.246.254.226 | GET "/favicon.ico"
@zq2599 ➜ /workspaces/blog_demos/tutorials/test003 (dev) $ go run main.go
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:   export GIN_MODE=release
 - using code:  gin.SetMode(gin.ReleaseMode)


[GIN-debug] GET    /                         --> main.main.func1 (3 handlers)
[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details.
[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default
[GIN-debug] Listening and serving HTTP on :8080
[GIN] 2023/02/04 - 14:10:22 | 200 |        58.7µs | 220.246.254.226 | GET      "/"
[GIN] 2023/02/04 - 14:10:22 | 404 |         900ns | 220.246.254.226 | GET      "/favicon.ico"
@zq2599 ➜ /workspaces/blog_demos/tutorials/test003 (dev) $ go run main.go [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. - using env: export GIN_MODE=release - using code: gin.SetMode(gin.ReleaseMode) [GIN-debug] GET / --> main.main.func1 (3 handlers) [GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. [GIN-debug] Environment variable PORT is undefined. Using port :8080 by default [GIN-debug] Listening and serving HTTP on :8080 [GIN] 2023/02/04 - 14:10:22 | 200 | 58.7µs | 220.246.254.226 | GET "/" [GIN] 2023/02/04 - 14:10:22 | 404 | 900ns | 220.246.254.226 | GET "/favicon.ico"
  • 再去看端口这个Tab页,如下图,发现gin监听的8080端口已经被forward到一个公网地址,点击红色箭头的图标,用浏览器访问这个地址
    在这里插入图片描述
  • 能够收到body响应,证明刚才的代码已经生效了,至此云端的IDE和运行环境都验证通过
    在这里插入图片描述
  • 至此,云端开发运行基本的web应用没问题了,咱们再试试数据库的部署和操作

验证之二:docker部署MySQL

  • go服务操作MySQL数据库是很常见的,这里咱们也在云开发环境验证一下
  • 现在的环境已部署了docker服务,所以用docker安装MySQL最省事儿,一行命令即可
docker run \
--name mysql \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=123456 \
-d \
mariadb:10.3
docker run \
--name mysql \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=123456 \
-d \
mariadb:10.3
docker run \ --name mysql \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=123456 \ -d \ mariadb:10.3
  • 微软服务器的网络情况真好,如下图,docker镜像下载得飞快
    在这里插入图片描述
  • 进入容器
docker exec -it mysql /bin/bash
docker exec -it mysql /bin/bash
docker exec -it mysql /bin/bash
  • 现在已经在MySQL容器中了,执行以下命令直接进入mysql命令行模式
mysql -uroot -p123456
mysql -uroot -p123456
mysql -uroot -p123456
  • 新建名为demo的数据库
create database demo;
use demo;
create database demo;
use demo;
create database demo; use demo;
  • 数据库准备完毕,接下来接着刚才的module继续开发,先安装gorm和MySQL驱动
go get -u gorm.io/gorm
go get -u gorm.io/driver/mysql
go get -u gorm.io/gorm
go get -u gorm.io/driver/mysql
go get -u gorm.io/gorm go get -u gorm.io/driver/mysql
  • 再在gin上新增一个路由,对应的操作是接收求参数,在数据库新增一条记录,由于代码过于简单就不多废话了,在下面直接全部贴出来
package main
import (
"fmt"
"strconv"
"github.com/gin-gonic/gin"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
type Student struct {
gorm.Model
Name string
Age uint64
}
// 全局数据库 db
var db *gorm.DB
// 包初始化函数,可以用来初始化 gorm
func init() {
// 账号
username := "root"
// 密码
password := "123456"
// mysql 服务地址
host := "127.0.0.1"
// 端口
port := 3306
// 数据库名
Dbname := "demo"
// 拼接 mysql dsn,即拼接数据源,下方 {} 中的替换参数即可
// {username}:{password}@tcp({host}:{port})/{Dbname}?charset=utf8&parseTime=True&loc=Local&timeout=10s&readTimeout=30s&writeTimeout=60s
// timeout 是连接超时时间,readTimeout 是读超时时间,writeTimeout 是写超时时间,可以不填
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", username, password, host, port, Dbname)
// err
var err error
// 连接 mysql 获取 db 实例
db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
if err != nil {
panic("连接数据库失败, error=" + err.Error())
}
// 设置数据库连接池参数
sqlDB, _ := db.DB()
// 设置数据库连接池最大连接数
sqlDB.SetMaxOpenConns(10)
// 连接池最大允许的空闲连接数,如果没有sql任务需要执行的连接数大于2,超过的连接会被连接池关闭
sqlDB.SetMaxIdleConns(2)
// 建表
db.AutoMigrate(&Student{})
}
func main() {
router := gin.Default()
router.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "hello world",
})
})
router.GET("/create", func(c *gin.Context) {
name := c.DefaultQuery("name", "小王子")
ageStr := c.DefaultQuery("age", "1")
var age uint64
var err error
if age, err = strconv.ParseUint(ageStr, 10, 32); err != nil {
age = 1
}
fmt.Printf("name [%v], age [%v]\n", name, age)
student := &Student{
Name: name,
Age: age,
}
if err := db.Create(student).Error; err != nil {
c.JSON(500, gin.H{
"code": 0,
"message": "insert db error",
})
return
}
c.JSON(200, gin.H{
"code": 0,
"message": fmt.Sprintf("insert db success [%+v]", student.Model.ID),
})
})
router.Run()
}
package main



import (
  "fmt"
  "strconv"

  "github.com/gin-gonic/gin"
  "gorm.io/driver/mysql"
  "gorm.io/gorm"
)

type Student struct {
  gorm.Model
  Name string
  Age  uint64
}

// 全局数据库 db
var db *gorm.DB

// 包初始化函数,可以用来初始化 gorm
func init() {
  // 账号
  username := "root"
  // 密码
  password := "123456"
  // mysql 服务地址
  host := "127.0.0.1"
  // 端口
  port := 3306
  // 数据库名
  Dbname := "demo"

  // 拼接 mysql dsn,即拼接数据源,下方 {} 中的替换参数即可
  // {username}:{password}@tcp({host}:{port})/{Dbname}?charset=utf8&parseTime=True&loc=Local&timeout=10s&readTimeout=30s&writeTimeout=60s
  // timeout 是连接超时时间,readTimeout 是读超时时间,writeTimeout 是写超时时间,可以不填
  dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", username, password, host, port, Dbname)

  // err
  var err error
  // 连接 mysql 获取 db 实例
  db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
  if err != nil {
    panic("连接数据库失败, error=" + err.Error())
  }

  // 设置数据库连接池参数
  sqlDB, _ := db.DB()
  // 设置数据库连接池最大连接数
  sqlDB.SetMaxOpenConns(10)
  // 连接池最大允许的空闲连接数,如果没有sql任务需要执行的连接数大于2,超过的连接会被连接池关闭
  sqlDB.SetMaxIdleConns(2)

  // 建表
  db.AutoMigrate(&Student{})
}

func main() {

  router := gin.Default()
  router.GET("/", func(c *gin.Context) {
    c.JSON(200, gin.H{
      "message": "hello world",
    })
  })

  router.GET("/create", func(c *gin.Context) {
    name := c.DefaultQuery("name", "小王子")
    ageStr := c.DefaultQuery("age", "1")

    var age uint64
    var err error
    if age, err = strconv.ParseUint(ageStr, 10, 32); err != nil {
      age = 1
    }

    fmt.Printf("name [%v], age [%v]\n", name, age)

    student := &Student{
      Name: name,
      Age:  age,
    }

    if err := db.Create(student).Error; err != nil {
      c.JSON(500, gin.H{
        "code":    0,
        "message": "insert db error",
      })

      return
    }

    c.JSON(200, gin.H{
      "code":    0,
      "message": fmt.Sprintf("insert db success [%+v]", student.Model.ID),
    })

  })
  router.Run()
}
package main import ( "fmt" "strconv" "github.com/gin-gonic/gin" "gorm.io/driver/mysql" "gorm.io/gorm" ) type Student struct { gorm.Model Name string Age uint64 } // 全局数据库 db var db *gorm.DB // 包初始化函数,可以用来初始化 gorm func init() { // 账号 username := "root" // 密码 password := "123456" // mysql 服务地址 host := "127.0.0.1" // 端口 port := 3306 // 数据库名 Dbname := "demo" // 拼接 mysql dsn,即拼接数据源,下方 {} 中的替换参数即可 // {username}:{password}@tcp({host}:{port})/{Dbname}?charset=utf8&parseTime=True&loc=Local&timeout=10s&readTimeout=30s&writeTimeout=60s // timeout 是连接超时时间,readTimeout 是读超时时间,writeTimeout 是写超时时间,可以不填 dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8&parseTime=True&loc=Local", username, password, host, port, Dbname) // err var err error // 连接 mysql 获取 db 实例 db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{}) if err != nil { panic("连接数据库失败, error=" + err.Error()) } // 设置数据库连接池参数 sqlDB, _ := db.DB() // 设置数据库连接池最大连接数 sqlDB.SetMaxOpenConns(10) // 连接池最大允许的空闲连接数,如果没有sql任务需要执行的连接数大于2,超过的连接会被连接池关闭 sqlDB.SetMaxIdleConns(2) // 建表 db.AutoMigrate(&Student{}) } func main() { router := gin.Default() router.GET("/", func(c *gin.Context) { c.JSON(200, gin.H{ "message": "hello world", }) }) router.GET("/create", func(c *gin.Context) { name := c.DefaultQuery("name", "小王子") ageStr := c.DefaultQuery("age", "1") var age uint64 var err error if age, err = strconv.ParseUint(ageStr, 10, 32); err != nil { age = 1 } fmt.Printf("name [%v], age [%v]\n", name, age) student := &Student{ Name: name, Age: age, } if err := db.Create(student).Error; err != nil { c.JSON(500, gin.H{ "code": 0, "message": "insert db error", }) return } c.JSON(200, gin.H{ "code": 0, "message": fmt.Sprintf("insert db success [%+v]", student.Model.ID), }) }) router.Run() }
  • 再次执行go run main.go运行应用,继续使用云开发环境给出的forward地址,如下图红色箭头所指,这次要在后面加上path和参数/create?name=Tom&age=10
    在这里插入图片描述
  • 浏览器成返回新增记录的id
    在这里插入图片描述
  • 登录MySQL查一下表,如下,数据全部写入成功
root@5e9f15ab9ac1:/# mysql -uroot -p123456
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.3.37-MariaDB-1:10.3.37+maria~ubu2004 mariadb.org binary distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> use demo;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
MariaDB [demo]> select * from students;
+----+-------------------------+-------------------------+------------+------+------+
| id | created_at | updated_at | deleted_at | name | age |
+----+-------------------------+-------------------------+------------+------+------+
| 1 | 2023-02-05 02:05:56.733 | 2023-02-05 02:05:56.733 | NULL | Tom | 10 |
| 2 | 2023-02-05 02:09:35.537 | 2023-02-05 02:09:35.537 | NULL | Tom | 10 |
| 3 | 2023-02-05 02:10:43.815 | 2023-02-05 02:10:43.815 | NULL | Tom | 10 |
| 4 | 2023-02-05 02:10:45.069 | 2023-02-05 02:10:45.069 | NULL | Tom | 10 |
| 5 | 2023-02-05 02:10:45.717 | 2023-02-05 02:10:45.717 | NULL | Tom | 10 |
| 6 | 2023-02-05 02:10:46.000 | 2023-02-05 02:10:46.000 | NULL | Tom | 10 |
| 7 | 2023-02-05 02:10:46.213 | 2023-02-05 02:10:46.213 | NULL | Tom | 10 |
| 8 | 2023-02-05 02:10:46.578 | 2023-02-05 02:10:46.578 | NULL | Tom | 10 |
| 9 | 2023-02-05 02:10:46.780 | 2023-02-05 02:10:46.780 | NULL | Tom | 10 |
| 10 | 2023-02-05 02:10:46.976 | 2023-02-05 02:10:46.976 | NULL | Tom | 10 |
| 11 | 2023-02-05 02:10:47.155 | 2023-02-05 02:10:47.155 | NULL | Tom | 10 |
| 12 | 2023-02-05 02:10:47.359 | 2023-02-05 02:10:47.359 | NULL | Tom | 10 |
+----+-------------------------+-------------------------+------------+------+------+
12 rows in set (0.000 sec)
root@5e9f15ab9ac1:/# mysql -uroot -p123456
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 42
Server version: 10.3.37-MariaDB-1:10.3.37+maria~ubu2004 mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> use demo;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [demo]> select * from students;
+----+-------------------------+-------------------------+------------+------+------+
| id | created_at              | updated_at              | deleted_at | name | age  |
+----+-------------------------+-------------------------+------------+------+------+
|  1 | 2023-02-05 02:05:56.733 | 2023-02-05 02:05:56.733 | NULL       | Tom  |   10 |
|  2 | 2023-02-05 02:09:35.537 | 2023-02-05 02:09:35.537 | NULL       | Tom  |   10 |
|  3 | 2023-02-05 02:10:43.815 | 2023-02-05 02:10:43.815 | NULL       | Tom  |   10 |
|  4 | 2023-02-05 02:10:45.069 | 2023-02-05 02:10:45.069 | NULL       | Tom  |   10 |
|  5 | 2023-02-05 02:10:45.717 | 2023-02-05 02:10:45.717 | NULL       | Tom  |   10 |
|  6 | 2023-02-05 02:10:46.000 | 2023-02-05 02:10:46.000 | NULL       | Tom  |   10 |
|  7 | 2023-02-05 02:10:46.213 | 2023-02-05 02:10:46.213 | NULL       | Tom  |   10 |
|  8 | 2023-02-05 02:10:46.578 | 2023-02-05 02:10:46.578 | NULL       | Tom  |   10 |
|  9 | 2023-02-05 02:10:46.780 | 2023-02-05 02:10:46.780 | NULL       | Tom  |   10 |
| 10 | 2023-02-05 02:10:46.976 | 2023-02-05 02:10:46.976 | NULL       | Tom  |   10 |
| 11 | 2023-02-05 02:10:47.155 | 2023-02-05 02:10:47.155 | NULL       | Tom  |   10 |
| 12 | 2023-02-05 02:10:47.359 | 2023-02-05 02:10:47.359 | NULL       | Tom  |   10 |
+----+-------------------------+-------------------------+------------+------+------+
12 rows in set (0.000 sec)
root@5e9f15ab9ac1:/# mysql -uroot -p123456 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 42 Server version: 10.3.37-MariaDB-1:10.3.37+maria~ubu2004 mariadb.org binary distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> use demo; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed MariaDB [demo]> select * from students; +----+-------------------------+-------------------------+------------+------+------+ | id | created_at | updated_at | deleted_at | name | age | +----+-------------------------+-------------------------+------------+------+------+ | 1 | 2023-02-05 02:05:56.733 | 2023-02-05 02:05:56.733 | NULL | Tom | 10 | | 2 | 2023-02-05 02:09:35.537 | 2023-02-05 02:09:35.537 | NULL | Tom | 10 | | 3 | 2023-02-05 02:10:43.815 | 2023-02-05 02:10:43.815 | NULL | Tom | 10 | | 4 | 2023-02-05 02:10:45.069 | 2023-02-05 02:10:45.069 | NULL | Tom | 10 | | 5 | 2023-02-05 02:10:45.717 | 2023-02-05 02:10:45.717 | NULL | Tom | 10 | | 6 | 2023-02-05 02:10:46.000 | 2023-02-05 02:10:46.000 | NULL | Tom | 10 | | 7 | 2023-02-05 02:10:46.213 | 2023-02-05 02:10:46.213 | NULL | Tom | 10 | | 8 | 2023-02-05 02:10:46.578 | 2023-02-05 02:10:46.578 | NULL | Tom | 10 | | 9 | 2023-02-05 02:10:46.780 | 2023-02-05 02:10:46.780 | NULL | Tom | 10 | | 10 | 2023-02-05 02:10:46.976 | 2023-02-05 02:10:46.976 | NULL | Tom | 10 | | 11 | 2023-02-05 02:10:47.155 | 2023-02-05 02:10:47.155 | NULL | Tom | 10 | | 12 | 2023-02-05 02:10:47.359 | 2023-02-05 02:10:47.359 | NULL | Tom | 10 | +----+-------------------------+-------------------------+------------+------+------+ 12 rows in set (0.000 sec)

桌面版

  • 可能有些读者对网页面的IDE心存顾虑:操作流畅度和体验方面与传统桌面版有差距,或者说习惯了桌面版(主要是不像欣宸这么穷,破电脑只够运行浏览器),这时候还可以用本地桌面版远程连接云开发环境,这时候编码在本地vscode,而编译运行还在之前的云环境进行,既解决了习惯问题,又不影响白嫖微软服务器,依旧是快乐满满,具体操作方法如下,点击红色箭头所指的菜单
    在这里插入图片描述

  • 此时浏览器就会拉起本地vscode
    在这里插入图片描述

  • 拉起的过程可能没那么顺利,会要求您的vscode登录GitHub账号,然后再重新拉起,多折腾几次就可以了,拉起后的效果如下,和在本地运行项目看不出区别
    在这里插入图片描述

  • 一切都符合预期,可见微软诚不欺我,4核8G服务器资源免费用,诚意满满

  • 这下似乎找不到偷懒的理由了,电脑破没关系,不想安装设置也没关系,没有服务器也没关系,GitHub都为你准备好了,还有什么理由不静下心来认真学习呢?

  • 了解更多codespaces详情,请访问官方资料:docs.github.com/zh/codespac…

欢迎关注掘金:程序员欣宸

学习路上,你不孤单,欣宸原创一路相伴…

© 版权声明
THE END
喜欢就支持一下吧
点赞0

Warning: mysqli_query(): (HY000/3): Error writing file '/tmp/MYZ3w4Xb' (Errcode: 28 - No space left on device) in /www/wwwroot/583.cn/wp-includes/class-wpdb.php on line 2345
admin的头像-五八三
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

图形验证码
取消
昵称代码图片