随笔分类 -  go杂记

摘要:关于go升级到go1.18.4之后代码提示失效问题 下载了go1.18.4之后安装到了E:/go1.8.4下面 go好像不能安装两个不同的版本, 会自动卸载之前安装的安装目录E:/go目录直接被清空 我在vscode全局的go settings.json文件中的"go.goroot":"E:\go" 阅读全文
posted @ 2022-07-26 21:24 楠海 阅读(167) 评论(0) 推荐(0) 编辑
摘要:1. protoc-gen-go 安装报错解决方法 报错: --go_out: protoc-gen-go: Plugin failed with status code 1. 解决方式: 1.go get -u github.com/golang/protobuf/protoc-gen-go@la 阅读全文
posted @ 2022-07-23 16:01 楠海 阅读(1382) 评论(1) 推荐(0) 编辑
摘要:1.统计字母出现的频率 面试官建议使用生产者消费者模型 type LetterFreq map[rune]int func CountLetters(strs []string, concurrency int) LetterFreq { if len(strs) < concurrency { c 阅读全文
posted @ 2022-02-12 14:40 楠海 阅读(78) 评论(0) 推荐(0) 编辑
摘要:630. 课程表 III 在看这道题的题解的时候总结下 package main import ( "container/heap" "sort" ) /* @如寒灬 的评论, https://leetcode-cn.com/u/wanyan/ 这是他的主页 为了更好的了解其贪心原则的使用我们来看看 阅读全文
posted @ 2021-12-14 13:42 楠海 阅读(119) 评论(0) 推荐(0) 编辑
摘要:使用fmt.XXX方法 package main import ( "bufio" "fmt" "os" "strings" ) var ( a string b int c bool ) func test_fmt() { n, err := fmt.Scanf("%s %d %t", &a, & 阅读全文
posted @ 2021-10-12 14:46 楠海 阅读(139) 评论(0) 推荐(0) 编辑
摘要:一些理解 内存使用: 虚拟内存是操作系统为每个进程提供的一种抽象,每个进程都有属于自己的、私有的、地址连续的虚拟内存,当然我们知道最终进程的数据及代码必然要放到物理内存上,那么必须有某种机制能记住虚拟地址空间中的某个数据被放到了哪个物理内存地址上,这就是所谓的地址空间映射,也就是虚拟内存地址与物理内 阅读全文
posted @ 2021-10-07 10:34 楠海 阅读(68) 评论(0) 推荐(0) 编辑
摘要:客户端代码 package main import ( "bufio" "fmt" "net" "os" "strings" ) func main() { // 连接服务端 conn, err := net.Dial("tcp", "127.0.0.1:8888") if err != nil { 阅读全文
posted @ 2021-10-03 10:15 楠海 阅读(30) 评论(0) 推荐(0) 编辑
摘要:复制到自己的编辑器, 从main函数看 package main import ( "fmt" "reflect" ) func reflectTest01(b interface{}) { //通过反射获取的传入的变量的 type , kind, 值 //1. 先获取到 reflect.Type 阅读全文
posted @ 2021-10-03 09:23 楠海 阅读(30) 评论(0) 推荐(0) 编辑
摘要:1. 入门 func print_hello() { // go 协成模型可以认真阅读, 常常见识 // https://i6448038.github.io/2017/12/04/golang-concurrency-principle/#:~:text=Go%E7%BA%BF%E7%A8%8B% 阅读全文
posted @ 2021-09-30 15:59 楠海 阅读(266) 评论(0) 推荐(0) 编辑
摘要:普通测试 package main import ( "fmt" ) func AddUpper(n int) int { res := 0 for i := 1; i <= n; i++ { res += i } return res } func main() { ans := AddUpper 阅读全文
posted @ 2021-09-29 15:39 楠海 阅读(38) 评论(0) 推荐(0) 编辑
摘要:从下往上看 package main import ( "bufio" "encoding/json" "flag" "fmt" "io" "io/ioutil" "os" ) type Monkey struct { Name string } type BirdAble interface { 阅读全文
posted @ 2021-09-29 14:28 楠海 阅读(42) 评论(0) 推荐(0) 编辑
摘要:上一次说明了, 原来的项目分配不是很好, 我又改了一个(但是因为没有使用数据库存储不能做到多用户注册登录功能) 项目目录 day01/familyaccount/model/account.go package model import "fmt" type AccountRecord struct 阅读全文
posted @ 2021-09-28 16:41 楠海 阅读(72) 评论(0) 推荐(0) 编辑
摘要:项目目录结构 familyaccount/main/main.go package main import ( utils "day01/familyaccount/utils" "fmt" ) func main() { var name, pwd string fmt.Println("请输入要 阅读全文
posted @ 2021-09-27 17:13 楠海 阅读(89) 评论(0) 推荐(1) 编辑
摘要:从下往上看, 可以复制到vscode中通过编辑器查看, 其中model/account.go表示model目录下的account.go文件, model是模块名 stu.go package main import "fmt" type Stud struct { Name string Age i 阅读全文
posted @ 2021-09-24 16:11 楠海 阅读(29) 评论(0) 推荐(0) 编辑
摘要:一些常用的东西(从下往上看) package main import ( "errors" "fmt" "math/rand" "strconv" "time" "unsafe" ) func test1() { var a int = 999 fmt.Println(a) var b uint = 阅读全文
posted @ 2021-09-18 13:40 楠海 阅读(55) 评论(0) 推荐(0) 编辑
摘要:func test2() { var str string = "hello 北京" for i := 0; i < len(str); i++ { fmt.Printf("str[%d]=%c\n", i, str[i]) // 按照字节遍历, 到中文时乱码 } /* str[0]=h str[1 阅读全文
posted @ 2021-09-10 11:45 楠海 阅读(167) 评论(0) 推荐(0) 编辑
摘要:package main import ( "strings" ) func blank(n int) string { return strings.Repeat(" ", n) } // 关于官网这种代码结构是在很让人失望, 所有处理都在同一个函数中很不好 func fullJustify(wo 阅读全文
posted @ 2021-09-10 11:04 楠海 阅读(71) 评论(0) 推荐(0) 编辑
摘要:package main import ( "container/heap" "sort" ) func findMaximizedCapital(k, w int, profits, capital []int) int { n := len(profits) type pair struct { 阅读全文
posted @ 2021-09-08 17:07 楠海 阅读(82) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示