diff --git a/C#.NET/README.md b/C#.NET/README.md index 48cb90c..30b7398 100644 --- a/C#.NET/README.md +++ b/C#.NET/README.md @@ -6,14 +6,19 @@ (支持:.net framework4.6.1+/.net core 2.0+/.net5/.net6+/mono5.4+/Unity 2018+/Xamarin/) ## 引用 nuget 包 -``` +```xml ``` +或者使用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(); ``` diff --git a/C/README.md b/C/README.md index 645ca4f..47fa6e4 100644 --- a/C/README.md +++ b/C/README.md @@ -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(); -``` - +``` \ No newline at end of file diff --git a/Go/README.md b/Go/README.md index 250e20a..cef452d 100644 --- a/Go/README.md +++ b/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: diff --git a/Java/README.md b/Java/README.md index b218a47..9f29e7d 100644 --- a/Java/README.md +++ b/Java/README.md @@ -5,7 +5,7 @@ JDK 1.8+ ## 引用 maven 包 -``` +```xml com.github.yitter yitter-idgenerator @@ -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(); ``` diff --git a/Rust/README.md b/Rust/README.md index bed9f5d..398a2d5 100644 --- a/Rust/README.md +++ b/Rust/README.md @@ -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(); -``` - - +``` \ No newline at end of file