Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
guanzhi committed Sep 29, 2023
1 parent b8ad513 commit 6352c18
Showing 1 changed file with 56 additions and 3 deletions.
59 changes: 56 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,64 @@ GmSSL-Go 是GmSSL密码库 https://github.com/guanzhi/GmSSL 的Go语言封装,

## 开发入门

GmSSL-Go的库代码位于`gmssl`目录下,示例位于`examples`目录下。在源代码的`examples`目录下执行
首先创建一个新项目,并初始化模块

```bash
go run .
$ mkdir hello
$ cd hello
```

可以执行默认的测试程序,查看`examples/hello.go`了解更多用法。
创建源文件`hello.go`

```go
package main

import (
"fmt"
"gmssl"
)

func main() {
fmt.Println(gmssl.GetGmSSLLibraryVersion())
}
```

```bash
$ go mod init example.com/hello
go: creating new go.mod: module example.com/hello
```

在项目模块中安装GmSSL-Go

```bash
$ go get github.com/GmSSL/GmSSL-Go@latest
go: added github.com/GmSSL/GmSSL-Go v1.3.0
```

打开文件`go.mod`,内容如下
```
module example.com/hello
go 1.21.1
require github.com/GmSSL/GmSSL-Go v1.3.0 // indirect
```

在文件`go.mod`最后面添加一行
```
replace gmssl => github.com/GmSSL/GmSSL-Go v1.3.0
```

更新模块信息
```bash
$ go mod tidy
go: found gmssl in gmssl v0.0.0-00010101000000-000000000000
```

编译执行
```bash
$ go build
$ go run .
GmSSL 3.1.1 Dev
```

0 comments on commit 6352c18

Please sign in to comment.