Merge pull request #51 from AuroraTea/master
docs: optimize highlight of code blocks in `readme.md`
This commit is contained in:
@@ -6,14 +6,19 @@
|
||||
(支持:.net framework4.6.1+/.net core 2.0+/.net5/.net6+/mono5.4+/Unity 2018+/Xamarin/)
|
||||
|
||||
## 引用 nuget 包
|
||||
```
|
||||
```xml
|
||||
<PackageReference Include="Yitter.IdGenerator" Version="1.0.*" />
|
||||
```
|
||||
或者使用nuget CLI时
|
||||
```shell
|
||||
nuget install Yitter.IdGenerator
|
||||
```
|
||||
更多引入方式请点击查看: [nuget.org/packages/Yitter.IdGenerator](https://www.nuget.org/packages/Yitter.IdGenerator)
|
||||
|
||||
## 调用示例(C#)
|
||||
|
||||
第1步,**全局** 初始化(应用程序启动时执行一次):
|
||||
```
|
||||
```cs
|
||||
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
||||
var options = new IdGeneratorOptions(Your_Unique_Worker_Id);
|
||||
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||
@@ -28,7 +33,7 @@ YitIdHelper.SetIdGenerator(options);
|
||||
```
|
||||
|
||||
第2步,生成ID:
|
||||
```
|
||||
```cs
|
||||
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
||||
var newId = YitIdHelper.NextId();
|
||||
```
|
||||
|
||||
@@ -6,11 +6,10 @@
|
||||
|
||||
2.如果是 Windows 环境,要用 Cygwin 或 MinGW。
|
||||
|
||||
|
||||
## 调用示例(C)
|
||||
|
||||
第1步,**全局** 初始化(应用程序启动时执行一次):
|
||||
```
|
||||
```c
|
||||
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
||||
IdGeneratorOptions options = BuildIdGenOptions(Your_Unique_Worker_Id);
|
||||
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||
@@ -25,8 +24,7 @@ SetIdGenerator(options);
|
||||
```
|
||||
|
||||
第2步,生成ID:
|
||||
```
|
||||
```c
|
||||
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
||||
long newId = NextId();
|
||||
```
|
||||
|
||||
```
|
||||
10
Go/README.md
10
Go/README.md
@@ -5,14 +5,14 @@
|
||||
项目更多介绍参照:https://github.com/yitter/idgenerator
|
||||
|
||||
## 引用全局库
|
||||
```
|
||||
```shell
|
||||
go get -u -v github.com/yitter/idgenerator-go
|
||||
```
|
||||
|
||||
## 调用示例(Go)
|
||||
|
||||
第1步,**全局** 初始化(应用程序启动时执行一次):
|
||||
```
|
||||
```go
|
||||
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
||||
var options = idgen.NewIdGeneratorOptions(Your_Unique_Worker_Id)
|
||||
// options.WorkerIdBitLength = 10 // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||
@@ -27,17 +27,17 @@ idgen.SetIdGenerator(options)
|
||||
```
|
||||
|
||||
第2步,生成ID:
|
||||
```
|
||||
```go
|
||||
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
||||
var newId = idgen.NextId()
|
||||
```
|
||||
|
||||
## 关于Go环境
|
||||
|
||||
1.SDK,go1.16
|
||||
1.SDK,go1.16+
|
||||
|
||||
2.启用 Go-Modules
|
||||
```
|
||||
```shell
|
||||
go env -w GO111MODULE=on
|
||||
|
||||
# Next *ONLY* for China-Users:
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
JDK 1.8+
|
||||
|
||||
## 引用 maven 包
|
||||
```
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.github.yitter</groupId>
|
||||
<artifactId>yitter-idgenerator</artifactId>
|
||||
@@ -16,7 +16,7 @@ JDK 1.8+
|
||||
## 调用示例(Java)
|
||||
|
||||
第1步,**全局** 初始化(应用程序启动时执行一次):
|
||||
```
|
||||
```java
|
||||
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
||||
IdGeneratorOptions options = new IdGeneratorOptions(Your_Unique_Worker_Id);
|
||||
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||
@@ -31,7 +31,7 @@ YitIdHelper.setIdGenerator(options);
|
||||
```
|
||||
|
||||
第2步,生成ID:
|
||||
```
|
||||
```java
|
||||
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
||||
long newId = YitIdHelper.nextId();
|
||||
```
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
## 调用示例(Rust)
|
||||
|
||||
第1步,**全局** 初始化(应用程序启动时执行一次):
|
||||
```
|
||||
```rust
|
||||
// 创建 IdGeneratorOptions 对象,可在构造函数中输入 WorkerId:
|
||||
let mut options = IdGeneratorOptions::New(Your_Unique_Worker_Id);
|
||||
// options.WorkerIdBitLength = 10; // 默认值6,限定 WorkerId 最大值为2^6-1,即默认最多支持64个节点。
|
||||
@@ -18,9 +18,7 @@ YitIdHelper::SetIdGenerator(options);
|
||||
```
|
||||
|
||||
第2步,生成ID:
|
||||
```
|
||||
```rust
|
||||
// 初始化后,在任何需要生成ID的地方,调用以下方法:
|
||||
long newId = YitIdHelper::NextId();
|
||||
```
|
||||
|
||||
|
||||
```
|
||||
Reference in New Issue
Block a user