从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
	}
}
相关推荐
XDHCOM20 小时前
ORA-32484重复列名错误,ORACLE数据库CYCLE子句故障修复与远程处理方案
数据库·oracle
Wenweno0o20 小时前
0基础Go语言Eino框架智能体实战-chatModel
开发语言·后端·golang
翻斗包菜20 小时前
PostgreSQL 日常维护完全指南:从基础操作到高级运维
运维·数据库·postgresql
呆瑜nuage21 小时前
MySQL表约束详解:8大核心约束实战指南
数据库·mysql
chenjingming66621 小时前
jmeter线程组设置以及串行和并行设置
java·开发语言·jmeter
liliangcsdn21 小时前
Agent Memory智能体记忆系统的示例分析
数据库·人工智能·全文检索
cch891821 小时前
Python主流框架全解析
开发语言·python
那个失眠的夜21 小时前
Mybatis延迟加载策略
xml·java·数据库·maven·mybatis
Rick199321 小时前
SQL 执行流程
数据库·sql
不爱吃炸鸡柳21 小时前
C++ STL list 超详细解析:从接口使用到模拟实现
开发语言·c++·list