goioc 介绍 goioc 是一个基于 GO 语言编写的依赖注入框架,基于反射进行编写。 支持泛型; 简单易用的 API; 简易版本的对象生命周期管理,作用域内对象具有生命; 延迟加载,在需要的时候才会实例化对象; 支持结构体字段注入,多层注入; 对象实例化线程安全,作用域内只会被执行一次。 下载依赖: go get -u github.com/whuanle/goioc v2.0.0 快速上手 定义接口: type IAnimal interface { Println(s string) } 实现接口: ty…

2022年11月27日 0条评论 3556点热度 0人点赞 痴者工良 阅读全文

Background: Unable to open remote settings. Also cannot open gpedit.msc. Repair Command (cmd): @echo off pushd "%~dp0" dir /b C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum >List.txt dir /b C:\Windows\s…

2022年11月26日 0条评论 3597点热度 0人点赞 痴者工良 阅读全文

背景: 打不开远程设置。 也打不开 gpedit.msc。 修复命令(cmd): @echo off pushd "%~dp0" dir /b C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientExtensions-Package~3*.mum >List.txt dir /b C:\Windows\servicing\Packages\Microsoft-Windows-GroupPolicy-ClientTools-Pack…

2022年11月26日 0条评论 4059点热度 0人点赞 痴者工良 阅读全文

WorkflowDefinitionValidator is the main entry point for validation, which has a very complex object structure. Reference: https://github.com/serverlessworkflow/specification/blob/main/specification.md By using dependency injection, the fields of the next layer…

2022年11月24日 0条评论 978点热度 0人点赞 痴者工良 阅读全文

WorkflowDefinitionValidator 是整个验证入口,上一个非常复杂的对象结构。 参考:https://github.com/serverlessworkflow/specification/blob/main/specification.md 通过依赖注入,继续检查下一层的字段。 /// <summary> /// Represents the service used to validate <see cref="WorkflowDefinition"/>s /// &…

2022年11月24日 0条评论 3348点热度 0人点赞 痴者工良 阅读全文

The code example is as follows: System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; services.ConfigureAll<HttpClientFactoryOptions>(options => { options.HttpMessag[......]继续阅读

2022年11月22日 0条评论 1006点热度 0人点赞 痴者工良 阅读全文

代码示例如下: System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; services.ConfigureAll<HttpClientFactoryOptions>(options => { options.HttpMessageHandlerBuilderActions.A[......]继续阅读

2022年11月22日 0条评论 3763点热度 0人点赞 痴者工良 阅读全文

Establishing Link SDK Official Repository Address: https://github.com/open-telemetry/opentelemetry-go Design an execution flow like this: Run executes Run1 and Run2 in sequence: a.Run1(newCtx) a.Run2(newCtx) Inside Run1, another function Run1-1 is also execute…

2022年11月20日 0条评论 1378点热度 1人点赞 痴者工良 阅读全文

建立链路 SDK 官方仓库地址: https://github.com/open-telemetry/opentelemetry-go 设计一个这样的执行流程: Run 先后执行 Run1、Run2: a.Run1(newCtx) a.Run2(newCtx) Run1 中,还执行了另一个函数 Run1-1。 使用 opentelemetry SDK 的代码示例如下: package main import ( "context" "go.opentelemetry.io/otel" "io" "log" ) //…

2022年11月20日 0条评论 5493点热度 1人点赞 痴者工良 阅读全文

package main import ( "fmt" "os" "os/signal" ) func main() { // Set up channel on which to send signal notifications. // We must use a buffered channel or risk missing the signal // if we're not ready to receive when the signal is…

2022年11月20日 0条评论 6522点热度 1人点赞 痴者工良 阅读全文

使用示例: package main import ( "fmt" "os" "os/signal" ) func main() { // Set up channel on which to send signal notifications. // We must use a buffered channel or risk missing the signal // if we're not ready to receive when the signal is sent. c := make(chan os…

2022年11月20日 0条评论 7469点热度 1人点赞 痴者工良 阅读全文

Usage Common log methods in Go: Print/Printf/Println : Print log information Panic/Panicf/Panicln : Print log information and call Panic with the formatted string as an argument Fatal/Fatalf/Fatalln : Print log information and exit the program with os.Exit(1) …

2022年11月20日 0条评论 3827点热度 0人点赞 痴者工良 阅读全文

使用 Go 中常用的 log 方法: Print/Printf/Println : 打印日志信息 Panic/Panicf/Panicln : 打印日志信息后,以拼装好的字符串为参数调用 Panic Fatal/Fatalf/Fatalln : 打印日志信息后,os.Exit(1) 退出程序 New 一个 Logger 的定义如下: func New(out io.Writer, prefix string, flag int) *Logger { return &Logger{out: out, pref…

2022年11月20日 0条评论 3838点热度 0人点赞 痴者工良 阅读全文

首先在要被执行的类型加上参数: [Option(Description = "CloudEvents 'source' (default: urn:example-com:mysource:abc)", LongName = "source", ShortName = "s")] private string Source { get; } = "urn:example-com:mysource:abc"; [Option(Descri…

2022年11月19日 0条评论 1284点热度 0人点赞 痴者工良 阅读全文

首先在要被执行的 类型 加上参数: [Option(Description = "CloudEvents 'source' (default: urn:example-com:mysource:abc)", LongName = "source", ShortName = "s")] private string Source { get; } = "urn:example-com:mysource:abc"; [Option(Description = "CloudEvents 'type' (default: …

2022年11月19日 0条评论 3775点热度 0人点赞 痴者工良 阅读全文

Introduce this library: YamlDotNet Configuration example: services.AddYamlDotNetSerializer( serializer => serializer .IncludeNonPublicProperties() .WithTypeConverter(new OneOfConverter()) .WithEmissionPhaseOb[......]继续阅读

2022年11月19日 0条评论 12980点热度 0人点赞 痴者工良 阅读全文

引入这个库: YamlDotNet 配置示例: services.AddYamlDotNetSerializer( serializer => serializer .IncludeNonPublicProperties() .WithTypeConverter(new OneOfConverter()) .WithEmissionPhaseObjectGraphVisitor(args => new Cha[......]继续阅读

2022年11月19日 0条评论 3904点热度 0人点赞 痴者工良 阅读全文

From ServerlessWorkflow, I learned an interesting configuration for NewtonsoftJson. var newtonsoftJsonDefaultConfig = (JsonSerializerSettings settings) => { settings.ContractResolver = new NonPublicSetterContractResolver(); settings.NullValu[......]继续阅读

2022年11月19日 0条评论 3909点热度 1人点赞 痴者工良 阅读全文

从 ServerlessWorkflow 中学习到一个有趣的 NewtonsoftJson 配置。 var newtonsoftJsonDefaultConfig = (JsonSerializerSettings settings) => { settings.ContractResolver = new NonPublicSetterContractResolver(); settings.NullValueHandling = NullValueHandling.Igno[......]继续阅读

2022年11月19日 0条评论 4053点热度 1人点赞 痴者工良 阅读全文

ISO 8601 specifies the time format. In Go language, Duration implements this time format. package main import ( "fmt" "time" ) func main() { t := time.Now() fmt.Println(t) } Output: 2022-11-19 02:59:28.201938781 +0000 UTC m=+0.000051897 In …

2022年11月19日 0条评论 4554点热度 0人点赞 痴者工良 阅读全文
1101112131454