从0开始学go 第一天

今天是开始学go的第x天,前些日子看了看语言,今天找一个web开发来跟着学,记录一下遇到的问题,方便以后复习查阅。

视频看的是https://www.bilibili.com/video/BV1gJ411p7xC?p=3&vd_source=ab5bdbd04f4142027c66d604d5285204

视频中用的是goland,我用的vs

如何在vs中建一个项目:

https://blog.csdn.net/sepnineth/article/details/125153354

这也是为了解决一个报错:

Go 复制代码
go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.
        To build and install a command, use 'go install' with a version,
        like 'go install example.com/cmd@latest'
        For more information, see https://golang.org/doc/go-get-install-deprecation
        or run 'go help get' or 'go help install'.

因为下载gin的时候会报错,就是这个命令:go get -u github.com/gin-gonic/gin

初次尝试go写一个网页还是挺有意思的

Go 复制代码
package main

import (
	"fmt"
	"net/http"
)

func sayHello(w http.ResponseWriter, r *http.Request) {
	_, _ = fmt.Fprintln(w, "Hello jzy")
}

func main() {
	http.HandleFunc("/hello", sayHello)
	err := http.ListenAndServe(":9090", nil)
	if err != nil {
		fmt.Printf("http server failed, err:%v\n", err)
		return
	}
}
相关推荐
道不尽世间的沧桑33 分钟前
第17篇:网络请求与Axios集成
开发语言·前端·javascript
久绊A41 分钟前
Python 基本语法的详细解释
开发语言·windows·python
夜泉_ly42 分钟前
MySQL -安装与初识
数据库·mysql
qq_529835352 小时前
对计算机中缓存的理解和使用Redis作为缓存
数据库·redis·缓存
月光水岸New4 小时前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
狄加山6754 小时前
数据库基础1
数据库
软件黑马王子4 小时前
C#初级教程(4)——流程控制:从基础到实践
开发语言·c#
我爱松子鱼4 小时前
mysql之规则优化器RBO
数据库·mysql
闲猫4 小时前
go orm GORM
开发语言·后端·golang
丁卯4045 小时前
Go语言中使用viper绑定结构体和yaml文件信息时,标签的使用
服务器·后端·golang