Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBlandy committed Sep 20, 2024
1 parent fd62d47 commit a02692b
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 45 deletions.
2 changes: 2 additions & 0 deletions Go/concurrent/协程.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ channel
* for 遍历 channel发送方在完成发送后必须调用 close(),for 才会退出
* 如果发送方不调用 close for 可能会导致死锁异常

* close 一个带缓冲区的 chan 如果 chan 中还有数据那么不能继续写入但可以继续读取直到读取完毕

* 缓冲区本质上是一个队列添加数据插入到尾部读取数据从头部读取
* 通过 cap 查看队列的缓冲区大小
* 通过 len 查看队列中有效元素的大小也就是尚未被读取的元素的数量
Expand Down
75 changes: 41 additions & 34 deletions Go/lib/bufio.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,17 @@ type

func (s *Scanner) Buffer(buf []byte, max int)
func (s *Scanner) Err() error
* 返回异常信息
* 返回异常信息如果是 EOF 异常则返回 nil
// 源码如下
if s.err == io.EOF {
return nil
}
return s.err

func (s *Scanner) Scan() bool
* 读取下一个分隔符返回结果表示是否还有数据
* 如果读取到末尾或者是异常则返回 false
* 此时可以通过 Err() 方法获取到异常

func (s *Scanner) Split(split SplitFunc)
* 指定分隔符如果不指定会使用newline字符作为分隔符
Expand Down Expand Up @@ -134,67 +141,67 @@ type
Demo
------------------------
# Scanner 扫描
package main

import (
"bufio"
"fmt"
"io"
"os"
)

func main() {
file, _ := os.Open("C:\\Users\\Administrator\\Desktop\\新建文本文档.txt")
defer file.Close()
file, err := os.Open("C:\\Users\\Administrator\\Desktop\\notes\\Google Authenticator.java")

if err != nil {
panic(err.Error())
}

defer func() {
_ = file.Close()
}()

scanner := bufio.NewScanner(file)
scanner.Split(bufio.ScanLines)
for {
if scanner.Scan() {
// 存在下一行数据
err := scanner.Err()
if err != nil {
if err != io.EOF {
// 异常
fmt.Fprintf(os.Stderr, "文件扫描异常:%s\n", err.Error())
return
}
}
// 以字符形式获取内容
text := scanner.Text()
fmt.Println(text)
} else {
break
}
for scanner.Scan() {
// 以字符形式获取内容
text := scanner.Text()
fmt.Println(text)
}

// 异常处理
if scanner.Err() != nil {
panic(scanner.Err())
}
}


# 读取标准输入流的输入
package main

import (
"bufio"
"fmt"
"io"
"os"
"strings"
)

func main() {

scanner := bufio.NewScanner(os.Stdin)
scanner.Split(bufio.ScanLines)
for scanner.Scan() {
err := scanner.Err()
if err != nil {
if err == io.EOF {
break
} else {
panic(err)
}
}
text := scanner.Text()
fmt.Println(text)

line := scanner.Text()
if strings.EqualFold(line, "bye") {
// 如果是 bye 就退出
if strings.EqualFold(text, "bye") {
break
}
fmt.Println(line)
}

// 异常处理
if scanner.Err() != nil {
panic(scanner.Err())
}
}

Binary file modified Google Authenticator.java
Binary file not shown.
22 changes: 11 additions & 11 deletions cmd命令.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@

# 获取文件的hash值
certutil -hashfile [文件] [hash算法]
# 获取文件的hash值
certutil -hashfile [文件] [hash算法]

* hash算法可以是: md5,sha1,sha256
* hash算法可以是: md5,sha1,sha256

# 清除由于网络问题带来的,maven依赖下载失败遗留的 .lastupdate/_remote.repositories文件
# 清除由于网络问题带来的,maven依赖下载失败遗留的 .lastupdate/_remote.repositories文件
for /r %i in (*.lastUpdated)do del %i
for /r %i in (*.repositories)do del %i

for /r %i in (*.lastUpdated)do del %i & for /r %i in (*.repositories)do del %i

* 需要在maven的仓库目录执行
* 需要在maven的仓库目录执行

# 使用 pause 指令让控制台 "请按任意键继续。。。"
# 使用 pause 指令让控制台 "请按任意键继续。。。"

# 修改cmd的字符集
# 修改cmd的字符集
CHCP
* 查看当前的编码默认为GBK(936)
* 查看当前的编码默认为GBK(936)
CHCP 65001
* 设置编码为utf-8
* 设置成功后如果不能正常显示,则尝试设置一下cmd属性里面的字体
* 设置编码为utf-8
* 设置成功后如果不能正常显示,则尝试设置一下cmd属性里面的字体

# 查看端口占用进程
# 查看端口占用进程

netstat -aon|findstr "8081"

Expand Down

0 comments on commit a02692b

Please sign in to comment.