Go语言中文网 为您找到相关结果 3683

Garson: Writing a simple router in go for learning purposes, would love to have feedback

<p>Hello guys, I am working on implementing a router on top of net/http, there is nothing fancy about it, and it&#39;s my first time to write a router &#34;or a useful package ever [imposter syndrome detected :D]&#34;. I hope you guys can give me a feeback on my golang skils and how to improve this little project, I already have w...阅读全文

Should i use Go in this project?

<p>Go is my favorite language by far. I&#39;m building a project to learn new things , it&#39;s a graphql proxy, and i&#39;m in doubt if Go is the best choice or not.</p> <p>The proxy gonna receive a unknow graphql query and do some processing behind the scenes with the response from origin. The problem is that the qu...阅读全文

资源 2017-05-07 10:00:09 xuanbao

Go web developer jobs?

<p>I&#39;m a 15 year old that&#39;s currently learning Go. I love it. Seriously, so much better than Node and Java for me. The thing is, when I look for jobs (well really I&#39;d be looking for an internship), I have like 5 results for Go, and hundreds for Java, JavaScript, etc. My question is this: is Go a language that you can m...阅读全文

How should I go about managing a task queue/worker system in Go?

<p>I have about 50 scheduled tasks that I need to run with goroutine every 10 minutes. In Python&#39;s django/flask we can use Celery for monitoring and error handling, and RabbitMQ for message queueing. I am not sure where to start right now, do I even need a message/task queueing in GO? I am also considering using Amazon&#39;s SQS t...阅读全文

图解kubernetes命令执行核心实现

K8s中的命令执行由apiserver、kubelet、cri、docker等组件共同完成, 其中最复杂的就是协议切换以及各种流拷贝相关,让我们一起来看下关键实现,虽然代码比较多,但是不会开发应该也能看懂,祝你好运 1. 基础概念 K8s中的命令执行中有很多协议相关的处理, 我们先一起看下这些协议处理相关的基础概念 1.1 Http协议中的Connection与Upgrade HTTP/1.1中允许在同一个链接上通过Header头中的Connection配合Upgrade来实现协议的转换,简单来说就是允许在通过HTTP建立的链接之上使用其他的协议来进行通信,这也是k8s中命令中实现协议升级的关键 1.2 Http协议中的101状态码 在HTTP协议中除了我们常见的HTTP1.1,还支持web...阅读全文

博文 2020-04-08 14:33:17 仔仔

Same file-reading algorithm, different results in Go and Ruby. What am I doing wrong?

<p>I&#39;m trying to hash only a small part of a large file. My approach is &#34;if the file is &lt; 1M bytes, SHA256 the entire thing; otherwise, SHA256 the first 100K bytes, then 500K bytes starting at len(file)/2.&#34;</p> <p>I wrote it in Ruby, which is hopefully readable even if you don&#39;t know Ruby:&l...阅读全文

【环境篇】搭建golang开发环境

image 学习一门语言,很多人都会是从搭建环境开始。有的语言的环境比较复杂,而有的语言环境很简单。对于go而言,说简单,的确不难,但有些概念需要先对其有所理解,才知道为什么这么用。网上对于怎么搭建一个golang开发环境已有了很多的教程,在这里我会简单介绍,不做过多描述。本篇文章仅对一些概念进行介绍,以及分享对一些我本人搭建开发环境的心得与技巧,如有错误,欢迎指正和交流。 搭建golang环境 1.到golang下载地址下载对应环境的安装包或者源码,若是Linux环境的话,将源码包下载解压之后,放至/usr/local/(实际上放至合适位置即可,只要把它添加进PATH就行),如: export PATH=$PATH:/usr/local/go/bin 2.配置GOPATH、GOROOT,这...阅读全文

博文 2020-01-14 03:32:45 onepunchgo

首发特性:goproxy.cn 现已推出首个 Go 模块代理统计数据 API

前言 这周很值得纪念,首先是 goproxy.cn 已缓存的模块版本总数突破了一百万,这甚至比起 Go 官方的 proxy.golang.org 已缓存的还要多出不少。其次是 goproxy.cn 的日访问量已稳定在千万级,正在朝着亿级进发,目前这在国内我了解到的别的几个同类服务中是最多的了。另外尤为重要的一点是,经过我们的不懈努力,甚至付出了两次事故的代价(详见:status.goproxy.cn),我们终于使得 goproxy.cn 达到了零错误率!现在的 goproxy.cn 可以说是很稳的了,大家可以放心使用。 刚刚在开头稍微为这一个月发生的事情做了个小总结。接下来说一下本次的重点,也就是 goproxy.cn 推出了 Go 模块代理世界中的首个统计数据 API(文档详见:gopro...阅读全文

博文 2020-03-30 23:35:16 煎鱼eddycjy

golang快速入门[2.3]-go语言开发环境配置-linux

linux安装Go语言开发包 默认读者会使用linux的基本操作 配置go语言的开发环境的第一步是要在go官网下载页面下载开发包 linux需要下载tar.gz压缩文件 image 这里我们下载的是 64 位的开发包,如果读者的电脑是 32 位系统或者有特殊的需求,则需要下载 32 位的开发包 在上图所示页面中向下滚动即可找到 32 位开发包的下载地址,如下图所示 image 注意,如果在ubuntu这样有图形化界面的linux操作系统,我们可以直接下载 没有图形化界面时,我们需要在命令行中操作 第一步:下载开发包 >> wget https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz --2020-02-06 14:18:58-- http...阅读全文

博文 2020-02-12 07:32:58 唯识相链2

golang学习--slice

切片定义 切片(Slice)是一个拥有相同类型元素的可变长度的序列。它是基于数组类型做的一层封装。它非常灵活,支持自动扩容。切片是一个引用类型,它的内部结构包含地址、长度和容量。切片一般用于快速地操作一块数据集合。 数组与切片 切片的数据实际是通过数组来保存的,每个切片都有三个信息:底层数组的指针、切片的长度(len)和切片的容量(cap)。 举个栗子,底层数组a := [8]int{0, 1, 2, 3, 4, 5, 6, 7}; 切片s1 := a[:5],切片和数组对应关系: Go-slice-2020-05-12-15-23-13 切片s2 := a[3:6],切片和数组对应关系: Go-slice-2020-05-12-15-44-43 指向同一个底层数组的切片修改值 切片是指向底...阅读全文

博文 2020-05-12 19:32:47 玖零儛

What's the most idiomatic API example for an enterprise golang server?

<p>&#34;Most idiomatic&#34; is subjective--and that&#39;s fine. What do you think is the most idiomatic golang server example on the internet? I&#39;m wanting to follow idiomatic patterns for the cli (spf13/cobra ?), for logging (logrus ?), for routing (net/http ?), middleware (std lib ?), for dockerizing (from scratch ?) etc....阅读全文

Advent of Code 2017 in Go

<p>I&#39;ve decided to use Advent of Code to keep learning Go this year; is anyone else participating? Would love to check out your repos if so; here&#39;s mine: <a href="https://gitlab.com/drakonka/advent-of-code-2017">https://gitlab.com/drakonka/advent-of-code-2017</a></p> <p>For those who aren&#...阅读全文

资源 2017-12-02 16:00:11 xuanbao

If you are compiling go binaries then just use scratch for the absolute smallest docker image possible.

<p>If you don&#39;t use TLS you don&#39;t even need the certs. Nothing will be small or have less attack surface.</p> <p>---- Dockerfile ----</p> <pre><code># Multi-stage builds make it easier to borrow automations and # artifacts from other images. The example below uses the alpine # package manager t...阅读全文

A leftpad fix?

<p>We probably need a community supported mirror for packages.</p> <p>Simplest way that I can think of goes something like this.</p> <p>in Gopkg.toml, add source as the community maintained mirror, like so</p> <p>```</p> <p>[[constraint]]</p> <p>name = &#34;github.com/user/p...阅读全文

资源 2018-02-09 02:30:10 agolangf

Go Web编程--应用数据库

今天我们继续接着前几篇关于Go Web编程的文章往下延伸。在Web应用程序中几乎每个应用场景都需要存储和检索数据库中的数据。当你处理动态内容,为用户提供表单以输入数据或存储登录名和密码凭据以供用户进行身份验证时,都需要用到数据库。 MySQL数据库是整个互联网中最常用的数据库。MySQL已经存在了很长时间,还在不停的进化并且随着互联网一起发展已多次证明了其位置和稳定性。 本文我们将探究Go中数据库访问的基础知识,在开始之前我们先更新一下我们使用的开发环境,之前在文章用Docker快速搭建Go开发环境 中我们只应用了一个运行 go的容器,现在我们为开发环境加上数据库。 关注文末公众号,回复gohttp04 获取容器编排文件和文章中用到的源代码。 在开发环境中增加MySQL容器 打开我们之前编写...阅读全文

博文 2020-02-13 14:34:19 kevinyan

leetcode_887

Golang: 思路:这题给跪了。。。 代码如下: func superEggDrop(K int, N int) int { if K==1{ return N } mat:=make([][]int,K+1) for k,_:=range mat{ mat[k]=make([]int,N+1) } for k,_:=range mat[1]{ mat[1][k]=k } for i:=2;i<=K;i++{ for j:=1;j<=N;j++{ low,high:=1,j for low+1mat[i][j...阅读全文

博文 2020-04-11 13:32:43 淳属虚构

Go-To Success Stories Please

<p>I am trying to pitch Go for use in U.S. federal systems. Is there anyone who can provide me with some success stories about where Go was approved for use. Accompanying testimonials are awesome, but even just examples of use would be great. I don&#39;t need details, just high level stuff like department/agency, maybe project title. Als...阅读全文

资源 2018-03-24 20:30:11 blov

Found an amazingly beginner resource for connecting to go's mysql database.

<p>If you want to try golang&#39;s webserver/database for free without installing anything. This isnt my project and I didnt build anything but it took me these 2 new years days off to finally figure all this out. Honestly db drivers and setting up a webserver and a database with a new language is kinda challenging and can take such a lo...阅读全文