Gone框架介绍24 - Gone vs Spring,写给想转 Go 的 Java程序员

【首发】Go-Spring基础教程 Go-Spring基础教程       最近想要转向golang,然后发现go的生态还不够强大,众所周知spring依托ioc和apo成为了一方霸主,私以为golang还是需要ioc的,遂在网上寻找包。发现有滴滴开源的go-spring,意图实现go语言上的springboot,只能说大厂还是相对有保证的。就先摸索了。GItee地址 github地址       虽说是大厂,但是文档真的很 阅读详情

Gone vs Spring,写给想转 Go 的 Java程序员

Gone是我们开发的 Golang 依赖注入框架,Spring是Java的依赖注入框架;为了便于Spring程序员转Golang快速上手Gone,我们在这里对他们的依赖注入做一下对比。

依赖模块导入

Spring

在项目管理工具中引入依赖;项目启动后自动扫描加载。
在 Maven 中 引入依赖

<dependency>
    <groupId>com.github.example</groupId>
    <artifactId>example</artifactId>
    <version>1.0.0</version>
</dependency>

在 Gradle 中 引入依赖

implementation 'com.github.example:example:1.0.0'

Gone

在MasterPriest函数中加载依赖模块提供的Priest函数;在启动前执行go mod tidy将依赖的包写入go.mod文件。

func MasterPriest(cemetery gone.Cemetery) error {
	_ = goner.XormPriest(cemetery) //加载xorm的依赖
	_ = goner.GinPriest(cemetery)  //加载gin的依赖

	_ = Priest(cemetery)
	return nil
}

func main() {
    gone.Run(MasterPriest)
}

注入依赖

Spring

在结构体属性上添加@Autowired注解,表示该属性是需要依赖注入的。

@Component
public class DemoController {

    @Autowired
    private IDemo demoSvc; //该属性是需要依赖注入的
}

Goner

在结构体属性上添加gone标签,表示该属性是需要依赖注入的,可以参考Gone支持哪些方式注入?

type demoController struct {
	gone.Flag
	demoSvc     service.IDemo `gone:"*"` //该属性是需要依赖注入的
}

配置注入

Spring

在结构体属性上添加@Value("${key}")注解,表示该属性是需要依赖注入的。

@Component
public class UseConfig {
    @Value("${my.conf.int}")
    private Integer int;
}


### Gone
在结构体属性上添加`gone:"config,${key},default=${defaultValue}"`标签,表示该属性是需要依赖注入的,可以参考[通过内置Goners支持配置文件](https://goner.fun/zh/guide/config.html)
```go
type UseConfig struct {
	gone.Flag

	int      int           `gone:"config,my.conf.int"`
	int8     int8          `gone:"config,my.conf.int8"`
	printInt *int          `gone:"config,my.conf.int8"` //指针 指向int
	float64  float64       `gone:"config,my.conf.float64"`
	string   string        `gone:"config,my.conf.string"`
	bool     bool          `gone:"config,my.conf.bool"`
	duration time.Duration `gone:"config,my.conf.duration"`
	defaultV string        `gone:"config,my.conf.default,default=ok"`

	sub *SubConf `gone:"config,my.conf.sub"` //指针,指向结构体

	subs []SubConf `gone:"config,my.conf.subs"` //数组
}

HTTP 参数注入

HTTP参数注入,就是自动读取HTTP请求的Query参数,并注入到Controller的方法中。

Gone支持多种HTTP参数注入,可以取到URL、Header、Body、Cookie、Form、Path等参数,
参考:HTTP 注入说明

注入Query参数

Spring
@RestController()
@RequestMapping("/demo")  //路由分组为/demo
public class CallbackController {

    @GetMapping("/hello") //GET方法,当前路由是/demo/hello
    public String hello(
            @RequestParam String name  //注入Query中的name参数
    ) {
        return "hello, " + name;
    }
}
Gone
type controller struct {
	gone.Flag
	rootRouter gone.RouteGroup `gone:"*"` //注入根路由
}

func (ctr *controller) Mount() gone.GinMountError {
	ctr.rootRouter.
		Group("/demo"). //路由分组为/demo

		//GET 方法
		GET(
			"/hello", // 当前路由是/demo/hello
			func(in struct {
				name string `gone:"http,query"` //注入Query中的name参数
			}) string {
				return "hello, " + in.name
			},
		)

	return nil
}

注入路径参数

Spring
@RestController()
@RequestMapping("/demo")  //路由分组为/demo
public class CallbackController {

    @GetMapping("/hell/{name}")//设置路径模式
    public String demo(
            @PathVariable(value = "name") String name //注入路径参数
    ) {
        return "hello, " + name;
    }
}
Gone
type controller struct {
	gone.Flag
	rootRouter gone.RouteGroup `gone:"*"` //注入根路由
}

func (ctr *controller) Mount() gone.GinMountError {
	ctr.rootRouter.
		Group("/demo"). //路由分组为/demo

		//GET 方法
		GET(
			"/hello/:name", //设置路径模式
			func(in struct {
				name string `gone:"http,param"` //注入路径参数
			}) string {
				return "hello, " + in.name
			},
		)

	return nil
}

请求体注入

Spring
@RestController()
@RequestMapping("/demo")  //路由分组为/demo
public class CallbackController {

    //订阅接收请求的POJO
    public static class Req {
        private String name;

        public String GetName() {
            return name;
        }

        public void SetName(String name) {
            this.name = name;
        }
    }

    @PostMapping("/hello")
    public String demo(
            @RequestBody Req req //注入请求体
    ) {
        return "hello, " + req.name;
    }
}
Gone
type controller struct {
	gone.Flag
	rootRouter gone.RouteGroup `gone:"*"` //注入根路由
}

func (ctr *controller) Mount() gone.GinMountError {
	type Req struct {
		Name string `json:"name"`
	}

	ctr.rootRouter.
		Group("/demo").
		POST(
			"/hello/:name", //注入请求体
			func(in struct {
				req Req `gone:"http,body"`
			}) string {
				return "hello, " + in.req.Name
			},
		)

	return nil
}

Gone支持多种HTTP参数注入,可以取到URL、Header、Body、Cookie、Form、Path等参数,
参考:HTTP 注入说明

总结

Spring和Gone在依赖模块导入、依赖注入、配置注入以及HTTP参数注入方面有不同的实现方式。

Spring通过项目管理工具(如Maven或Gradle)引入依赖,并自动扫描加载依赖模块。依赖注入使用@Autowired注解,配置注入使用@Value("${key}")注解,HTTP参数注入则通过@RequestParam、@PathVariable和@RequestBody注解实现。

相对而言,Gone在MasterPriest函数中手动加载依赖模块,通过gone标签进行依赖和配置注入,并支持多种HTTP参数注入方式(如URL、Header、Body、Cookie、Form、Path等),灵活处理HTTP请求参数。

求赞助

如果觉得还可以,请帮忙在github上点个 ⭐️吧:
github地址:https://github.com/gone-io/gone

福利:🔥添加交流群,赠送 Golang 多套 学习资料,夯实基础👍🏻👍🏻

上一篇:Gone框架介绍23 - Gone对Xorm的一点点增强

SpringBoot与Gin框架:全方位性能对比揭秘 通过多角度的性能对比分析和具体的测试数据,我们可以看到SpringBoot和Gin框架各自具有独特的优势和特点。SpringBoot框架提供了丰富的功能和解耦的组件,适用于大型企业级应用程序。而Gin框架则具有高性能、低内存占用和简洁的API设计,适用于构建轻量级的RESTful API应用程序。 阅读详情

相关推荐

Go-Spring: 一个类似于 Java Spring 全家桶的 GoLang 应用程序框架

总结来说,Go-Spring 是一个模仿 Java Spring 全家桶实现的 GoLang 应用程序框架,旨在提供与 Spring 类似的特性和开发体验。通过使用 Go-Spring,开发者可以用熟悉的方式构建和管理 GoLang 应用程序,从而提高开发效率并降低维护成本。它的目标是让开发者能够用熟悉的方式来构建和管理 GoLang 应用程序,提供类似于 Spring 的依赖注入、控制反转、面向切面编程等特性。开发者可以根据自己的需求选择适合的功能来构建和扩展应用程序。的控制器,并定义了一个。

BcpiDev的博客 1078

Gone框架介绍6 - 如何使用gone开发web服务

我在两年前实现了一个Golang的依赖注入框架,并且集成了gin、xorm、redis、cron、消息中间件等功能,自己觉得还挺好用的;之前一直没有时间写文档推广,现在"毕业了",有时间来完善完善了。github地址:https://github.com/gone-io/gone。如果有可能,请帮忙在github上点个 ⭐️?规范上,我们要求将服务的接口定义在。编写http接口,我们需要实现。方法中实现接口路由的挂载,如。文件:i_demo.go。服务的逻辑实现,放到。

大鹏的技术博客 1321

实用电路精讲系列---快速精密桥式放大器电路

快速精密桥式放大器通过惠斯通电桥转换物理量为差分信号,经仪表放大器精密放大,具有高共模抑制、低噪声和宽带宽特性。其核心包含:电桥传感器转换、仪表放大器信号调理(增益可调、温漂补偿)、输出级适配ADC。典型应用包括智能断路器监测、胎压检测、电池安全预警等10大领域,需注意传感器-放大器-ADC最短路径布局。实用电路采用LT1057S和LT1010构建,实现稳定供电、差分处理、功率放大和桥式驱动,满足高精度、快速响应需求。该技术在工业控制、医疗设备等领域具有重要价值。

weixin_40590799的博客 1414

Gone框架模块化改造之路

本文详细介绍了Gone框架从单一仓库到模块化架构的改造过程。Gone是一个轻量级的Go语言依赖注入框架,通过将各功能组件(Goner)分离为独立模块,解决了依赖膨胀、版本管理困难等问题。文章阐述了改造背景、实施过程、技术挑战及解决方案,包括接口抽象、单仓库多模块管理和依赖解耦等核心技术。这次改造使Gone更符合"小而美"的设计理念,为开发者提供了更灵活、高效的组件化开发体验。

大鹏的技术博客 1196

LAMMPS模拟新合金没势函数?手把手教你用`pair_style hybrid`混合势函数(附FeCMnSiTi案例)

本文详细介绍了在LAMMPS中如何使用`pair_style hybrid`混合势函数模拟新型高熵合金(如FeCMnSiTi),解决缺乏现成势函数的问题。通过实战案例,涵盖参数查找、命令编写、错误排查等关键步骤,特别适合处理多组元体系的复杂相互作用。文章还提供了EAM势函数与LJ势的组合技巧,帮助研究者准确模拟合金性能。

weixin_30635053的博客 243

MyEclipse 2017 CI 10安装与激活

本文介绍MyEclipse 2017 CI 7、CI 8、CI 9和CI 10的安装与激活。此方法理论上应该能激活MyEclipse 2017 CI所有系列,即激活方法是通用的,只是激活文件略有不同。本文提供MyEclipse 2017 CI 7、CI 8、CI 9和CI 10的激活文件。说明:博主所提供的压缩包格式均为RAR5,即WinRAR 5.0以上的版本才能正常解压,别的压缩软件博主不太清...

weixin_42539046的博客 9416

Gone框架介绍31 - 使用`goner/zap`替代logrus默认实现,提升日志输出的效率

goner/zapgone是可以高效开发Web服务的Golang依赖注入框架。

大鹏的技术博客 967

Supervisor 安装与使用

一、Supervisor 介绍 Supervisor 是一个用 Python 编写的进程管理工具,它可以用于监控和控制类 UNIX 操作系统上的多个进程。它是一个客户端/服务器系统,其中 Supervisor 的服务器端称为 supervisord,负责启动管理的子进程、响应客户端命令、重启崩溃或退出的子进程、记录子进程的 stdout 和 stderr 输出,以及处理子进程生命周期中的事件。客...

疯子丶pony的博客 3863

Go的Gin比java的Springboot更加的开箱即用?

隔壁组的云计算零零后女同事,后文简称 云女士 ,非说 Go 的 Gin 框架比 Springboot 更加的开箱即用,我心想在 Java 里面 Springboot 已经打遍天下无敌手,这份底蕴岂是 Gin 能比。但是云女士突出一个执拗,非我要 PK 一把, PK 内容就是她使用 Gin,而我使用 Springboot 快速搭建一个简单的 Crud 工程,最后让其他同事来评判哪个更开箱即用。我毫不犹豫就答应了,作为搭建 Springboot 学习工程的资深 Crud 选手,咱这份底气还是有的。

王二的博客 1584

[HQChart教程] 去掉“仅学习使用”文字提示的小技巧

最近用 HQChart 做图表时,发现左下角有“仅学习使用”的字样。这种水印虽然是默认的,但如果要展示给客户,可能会显得不够专业。还好,这个问题很好解决,只需要简单修改一下配置。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 598

提示词驱动的多智能体协作系统

《提示词驱动的多智能体协作系统》 关键词:人工智能、多智能体系统、协作机制、提示词驱动、系统设计与应用 摘要:本文深入探讨提示词驱动的多智能体协作系统,首先介绍其背景和核心概念,然后详细分析多智能体系统的基本原理和提示词驱动的协作机制,最

AI天才研究院 849

Java Spring Boot 与 Go(Golang)

随着后端框架的不断发展,开发人员面临着在项目中选择还是**Go (Golang)**的关键问题。这两个框架都功能强大,但适用于不同的用例。本文提供了详细的比较,并提供了技术基准、实际示例和用例场景,帮助开发人员做出明智的选择。

qq_28791753的博客 3972

labview高低拼接的理解

计算机的一个字节由8位组成,无符号的8位整形表示的范围为0~255,范围太小了,所以用双字节,即16位整形表示更大范围的数字0 ~65535。2.labview中的高低拼接实质是高8位字节左移8位与低8位字节相加,结果是双字节整形。

qwerqwerdhr的博客 835

写给 Javaer 看的 Go Gin 教程

在国内,Gin 被广泛认为是使用最为广泛的 Go 语言 Web 开发框架。它以高性能和简洁的 API 设计而著称,特别适合构建高并发的服务。此外,Kratos 作为 B 站开源的微服务框架,也在国内拥有一定的用户基础,适用于构建复杂的分布式系统。其他流行的 Go 语言 Web 框架还包括 Beego、Echo 和 GoFrame 等,它们各自提供不同的特性,满足开发者的多样化需求。

长河的博客 1663

28、数字电路测试与半导体内存测试全解析

本文全面解析了数字电路中的顺序电路测试生成方法与半导体内存测试技术。内容涵盖顺序电路中的故障检测、多重观察测试、可驱动性分析、伪组合电路测试及初始化问题,并深入探讨了内存技术发展、故障模型、测试流程与未来趋势。重点介绍了DRAM、SRAM等主流内存类型的特点,以及制造和使用过程中面临的永久性与非永久性故障挑战,提出了基于故障模型的高效测试策略与优化方案。

go5gopher的博客 122

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

gin框架基本使用

在go的web项目中,gin相当于java中的springmvc、gorm相当于java中的mybatis、gomod相当于java中的maven。gin的中文文档。

m0_64288219的博客 6074

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

用golang搭建springboot风格项目结构 gin+gorm

用Go语言来搭建一个springboot风格的web项目结构,web层使用gin框架,数据持久层使用gorm框架

魑魅魍魉 4538

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Java VS Go 还在纠结怎么选吗,(资深后端4000字带你深度对比)

Go的优点代码简洁性静态类型可编译成机器码直接运行天生多核并行垃圾收集跨平台且不依赖运行时环境简洁的泛型内置安全性缺点有限的库支持泛型不够完善灵活度没Java高(这个可算优点也可算缺点)Java的优点优秀的文档优秀的三方库多线程灵活性高平台独立性完善的语言特性垃圾回收JVM缺点垃圾回收效果不佳大量冗余的陈旧实现导致性能不佳代码的复杂性复杂的继承机制。...

weixin_70730532的博客 1万+

golang 框架_模仿 Java 的 Spring 全家桶实现的一套 GoLang 的应用程序框架

Go-Spring 项目简介Go-Spring 是模仿 Java 的 Spring 全家桶实现的一套 GoLang 的应用程序框架,遵循“习惯优于配置”的原则,提供了依赖注入、自动配置、开箱即用、丰富的第三方类库集成等功能,能够让程序员少写很多的样板代码。完整的 go-spring 项目一共包含 6 个模块,当前模块仅实现了基础的 IOC 容器的能力,该模块可以独立使用,但是配合其他模块才能使得效...

weixin_39798497的博客 1271

[goa]golang微服务框架学习--安装使用

当项目逐渐变大之后,服务增多,开发人员增加,单纯的使用go来写服务会遇到风格不统一,开发效率上的问题。 之前研究go的微服务架构go-kit最让人头疼的就是定义服务之后,还要写很多重复的框架代码,一直再想如何使用IDL描述服务,然后自动生成框架代码。 直到遇到老这货 goa,另外一个go的微服务框架。具体介绍看这篇,还有官网。 这货实现了框架的代码自动生成(自动生成的代码可以热更...

weixin_30915275的博客 407

微服务架构选Java还是选Go - 多用户负载测试

Ivan Nikitsenka 微服务架构允许我们再创建新应用时自由选择不同的技术和编程语言。不过究竟哪种语言更适合我们当下的硬件?回答这个问题,需要搞明白Java和Go编写的相同应用程序之间的性能差异。 先决条件 No additional performance enhancements should be applied. Use minimum configurations with de...

weixin_34233856的博客 713

golang获取post内容_beego Vs Springboot,Java与Golang的性能对决,谁能赢?

作为目前最火的语言,Java已经显得老态龙忠了,听到最多的抱怨就是臃肿,性能低,开发部署麻烦,甚至连脚本语言PHP都携swoole想趁机打一驾,真的是这样的吗?其实真正做过Java开发的是不可能说出 Java开发部署麻烦这种话的,maven引入,Springboot一把梭,面向对象的语法虽然繁琐但是贴近口语话,开发是一件很轻松的事情了。那么剩下的就是性能问题了。作为明星的Golang语言最近几年风...

weixin_36307834的博客 1288

golang的web框架—beego的api(强烈推荐)

学习地址:  https://beego.me/docs/intro/

skh2015java的博客 9584

java动态路由_动态路由:GinvsSpringMVC

深入理解java虚拟机 jvm高级与佳三87.8元包邮(需用券)去购买 >这两天在接触Gin,对它的动态路由功能比较感兴趣,特意做了笔记,顺便跟SpringMVC作下对比。1.简介Gin是使用Go/golang语言实现的HTTP Web框架。接口简洁,性能极高。截止1.4.0版本,包含测试代码,仅14K,其中测试代码9K左右,也就是说框架源码仅5K左右。SpringMVC不用过多介绍,Jav...

weixin_42365492的博客 673

go c++ 效率 递归_Go+iris吊打Java+SpringBoot,是Java老了吗?且慢,Vert.x有话要说

前文回顾之前做过一个测评,是用Go语言的iris框架与Java的SpringBoot框架做了个性能对比,测试了三项,结果SpringBoot全线溃败,详情见:MakeLoveTech:Go语言现在为什么这么火?Go+Iris vs Java+SpringBoot 为您揭晓答案​zhuanlan.zhihu.com那个结果很容易给人一个错觉:是java老了吗?当然不是!Java界的性能担当根本就不是...

weixin_39673293的博客 507

golang语法总结(二十一):方法method

Go不像其它面相对象语言一样可以写个class,然后在class里面写一堆方法,但是它也很巧妙的实现了这种效果,我们只需要在普通函数前面加个接受者(receiver,写在函数名前面的括号里面),这样编译器就知道这个函数(方法)属于哪个struct了。     下面是简单示例: type A struct { Name string} func (a A)foo() { //接收者

陈鹏万里 4630
上一篇: 如何将老板的游戏机接入阿里云自建K8S跑大模型(上) - 如何去掉pritunl中的NAT
下一篇: 如何在阿里云上自建NAT服务器来访问外网
dapeng-大鹏
博客等级 码龄16年 1349粉丝 116原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

dapeng-大鹏

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值