Why is every Go community I visit so harsh ?
<p>I am a self taught programmer. I have been studying programming for several years and as such I rely on places like this and stackoverflow to ask questions I haven't been able to find answers to on my own. I started studying Go a couple of months ago. Since then I have been met more often with contempt and or down votes on every pl...阅读全文
Linux下使用-static -lpthread静态编译出现段错误(Segmentation fault)
发自:https://blog.csdn.net/godmaycry/article/details/78718399最近在看golang,感觉go的静态编译思想很不错。于是准备把手头的几个项目静态编译一下,结果编译的时候没报任何警告及错误,一运行就报段错误(Segmentation fault)。gdb逐步调试,发现问题出在std::thread那里。仔细检查了下所有语法,没发现任何问题。关键是动态编译一切正常,加了-static静态编译就会出现这个问题。Google才发现这是一个bug,std::thread Segmentation fault static linking解决方案有两个:1.参数加上-Wl,--whole-archive -lpthread -Wl,--no-whol...阅读全文
How to read from user input without the \n ?
<p>How to read from user input without the \n ?</p> <pre><code> reader := bufio.NewReader(os.Stdin) fmt.Print("Enter text: ") port, _ = reader.ReadString('\n') port = strings.Replace(port, "\n", "", -1) </code></pre> ...阅读全文
Unable to install Go 1.9 on Ubuntu, please help
<p>Hi I am on Ubuntu. I have installed Go 1.6 but I want to explore hyper ledger and they need go 1.9, so I followed all instructions from this post, but after doing everything when I enter go version, it again returns 1.6 and not 1.9. URL: <a href="https://medium.com/@patdhlk/how-to-install-go-1-9-1-on-ubuntu-16-04-ee64c073cd79" ...阅读全文
Why does the Go project's commit history date back to 1972?
<p>Type <code>git log</code>, hit "End", and you'll see these four commits:</p> <pre><code>commit d82b11e4a46307f1f1415024f33263e819c222b8 Author: Brian Kernighan <bwk@research.att.com> Date: Fri Apr 1 02:03:04 1988 -0500 last-minute fix: convert to ANSI C R=dmr ...阅读全文
How to deploy golang?
<p>Hi,</p> <p>I am new in golang. I develop web api using golang on mac os. My production environment is ubuntu 14.04 on Digitalocean. How can I deploy golang? what is the bast practice? How can I use docker? </p> <hr/>**评论:**<br/><br/>silenceofnight: <pre><p>You can pretty much just c...阅读全文
初识GoLang
1、概念 Go 是一个开源的编程语言,它能让构造简单、可靠且高效的软件变得容易。Go是从2007年末由Robert Griesemer, Rob Pike, Ken Thompson主持开发,后来还加入了Ian Lance Taylor, Russ Cox等人,并最终于2009年11月开源,在2012年早些时候发布了Go 1稳定版本。现在Go的开发已经是完全开放的,并且拥有一个活跃的社区。 2、特点 简洁、快速、安全 Go语言语法简单易学、学习曲线平缓,相比于C/C++,Go语言具有很高的开发效率。 并行、有趣、开源 Go语言为高并发而生。 代码风格统一,便于阅读。 Go语言使用go fmt,统一格式化代码。 3、安装 下载地址 下载对应平台下的文件,使用下一步安装法。 image.png ...阅读全文
从filebeat dns解析失败到alpine兼容性和go内部dns实现
最近一周都在解决filebeat dns解析失败的问题。filebeat通过daemonset方式部署在k8s集群中,从而收集整个主机pods的日志。在主机os为centos7.4 的版本集群中,没有任何问题。但是os为centos7.6的集群中,却出现了解析dns失败,导致日志无法发送到kafka集群。 查看filebeat错误日志如下: Failed to connect to broker sg.main2.kafka.metis.service:9092: dial tcp: lookup sg.main2.kafka.metis.service: Try again 于是开启了debug过程,首先怀疑是coredns出了问题,去exec到pod中进行dig。 dig @[10.24...阅读全文
github-webhook工具实现github自动构建
理 当本地git push origin master向Github远程仓库提交代码时,可以通过配置github自带webhook向服务器发送请求,利用github-webhook工具在服务器端接到请求后,调用自定义shell脚本来实现自动构建 github-webhook 文档 更多详情文档 github.com/yezihack/gi… 使用github-webhook 源码: github.com/yezihack/gi… 别忘记点个小星星哦. 1. 下载github-webhook工具 github.com/yezihack/gi… github release下载太慢, 试试这个 wget http://img.sgfoot.com/github-webhook1.4.1.linu...阅读全文
[Part-Time Job] Looking for my replacement
<p>Not sure if there is a better place to post this or not. If there is let me know and I'll take this down and put it up wherever it belongs.</p> <p>I've been working part-time for about a year for a friend's startup building a product using Go. I'm starting school up again and I'm going t...阅读全文
搭建golang开发环境
cd /www/server && yum install -y wget && wget -O golang.tar.gz https://dl.google.com/go/go1.12.5.linux-amd64.tar.gz tar -xzvf golang.tar.gz wget -O profile.txt https://lowvps.cn/wp-content/uploads/2019/05/profile.txt cat profile.txt >> /etc/profile source /etc/profile mkdir /www/wwwroot/Golang echo -e "----------------------------------------------...阅读全文
Golang交叉编译
Golang 支持交叉编译,在一个平台上生成另一个平台的可执行程序,最近使用了一下,非常好用,这里备忘一下。 Mac 下编译 Linux 和 Windows 64位可执行程序 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go Linux 下编译 Mac 和 Windows 64位可执行程序 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go Wind...阅读全文
Suggest me your favourite "terminal GUI" libs
<p>For an upcoming tool I want <a href="http://i.ytimg.com/vi/HZLt2KT4aLA/maxresdefault.jpg">an in-terminal GUI</a> (not <em>exactly</em> like it, just to show roughly what I even mean by "terminal GUI" ;)</p> <p>Y'know, arrow-key-navigable menus, perhaps a list view / maste...阅读全文
Go工具和调试详解
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/happyAnger6/article/details/78724594 工具集 go build -gcflags: 传递给编译器的参数 -ldflags: 传递给链接器的参数 -work: 查看编译临时目录 -race: 允许数据竞争检测(仅支持amd64) -n: 查看但不执行编译指令 -x: 查看并执行编译命令 -a: 强制重新编译所有依赖包 -v: 查看被编译的包名,包括依赖包 -p n:并行编译所使用的CPU数,默认为全部 -o:输出文件名 gcflags: -B 禁用边界检查 -N 禁用优化 -l 禁用函数内联 -u 禁用unsafe代码 -m 输出优化信息 -S 输出汇编代码 l...阅读全文
Do you know projects that are compiles as shared libraries?
<p>I’m considering Go for a new project that is supposed to be usted by other languages. So, the solution seems to be to create a shared library (Linux only).</p> <p>I know this can be done with cgo, but I would like to see a real project that uses the same model. </p> <p>Does anyone knows about a project that is use...阅读全文
Go 语言环境安装
Go 语言环境安装 Go 语言支持以下系统: Linux FreeBSD Mac OS X(也称为 Darwin) Window 安装包下载地址为(go语言环境配置安装包下载安装教程): https://golang.org/dl/ 各个系统对应的包名: Go 语言环境安装 UNIX/Linux/Mac OS X, 和 FreeBSD 安装 以下介绍了在UNIX/Linux/Mac OS X, 和 FreeBSD系统下使用源码安装方法: 1、下载源码包:go1.4.linux-amd64.tar.gz。 2、将下载的源码包解压至 /usr/local目录。 tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz 3、将 /usr/local/go/bi...阅读全文
Can I run go on a Raspberry Pi 3 running FreeBSD?
<p>Edit. Looks like [not] - FreeBSD runs only in aarch64 mode on the Raspberry Pi and Go <a href="https://golang.org/doc/install/source">doesn't support FreeBSD/aarch64</a>.</p> <hr/>**评论:**<br/><br/>jackmott2: <pre><p>I do not know but I know you can run Go on a Raspberry Pi run...阅读全文
Golang dev environments with Docker
<p>How are developers setting up their dev environments for Golang with Docker? I setup a multi-stage Docker file, but then it seems i have to build the container every time I want to try out my changes. Is this the best practice or is there a better way?</p> <pre><code>FROM golang:1.9.2 as builder RUN mkdir -p /go/src/gi...阅读全文
golang环境安装
环境安装 源码安装go 1.下载go安装包源码 到 https://golang.org/dl/ 选定自己想要安装的 go 版本,使用如下命令下载 go 源码。 wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz 2.解压到(目标目录,可以可以自己指定) tar -zxvf go1.10.3.linux-amd64.tar.gz -C ~/src 3.配置~/.bashrc(对应步骤 2 中的目标目录) export GOPATH=~/GoWorkspace export GOROOT=~/src/go export PATH=$GOROOT/bin:$GOPATH/bin:$PATH 4.查看当前 go 版本 ~$ go ve...阅读全文
2.安装
安装Go语言及搭建Go语言开发环境 注意:Go语言1.14版本之后推荐使用go modules管理以来,也不再需要把代码写在GOPATH目录下了,之前旧版本的教程戳这个链接。 下载 下载地址 Go官网下载地址:https://golang.org/dl/ Go官方镜像站(推荐):https://golang.google.cn/dl/ 版本的选择 Windows平台和Mac平台推荐下载可执行文件版,Linux平台下载压缩文件版。 下图中的版本号可能并不是最新的,但总体来说安装教程是类似的。Go语言更新迭代比较快,推荐使用较新版本,体验最新特性。 download1 安装 Windows安装 此安装实例以 64位Win10系统安装 Go1.14.1可执行文件版本为例。 将上一步选好的安装包下载...阅读全文
Hello Gophers.
<p>Hi,</p> <p>I guess I should probably write something about my plans going forward.</p> <p>First, I obviously can't do this alone. I've asked <a href="/u/natefinch">/u/natefinch</a> and <a href="/u/peterbourgon">/u/peterbourgon</a>, two respected Gophers to h...阅读全文
Golang系列之Go语言入门(一)
序列-Go语言来源 Golang是一门年轻而有活力的语言,2007年Robert、Rob和Ken 在Google开发,于2009年正式发布; Go语言的初衷:作者们希望能使复杂的、高效系统的编写变得简单、可靠;同时也期望Go能成为一个相对通用的编程环境,推崇少即是多的概念、 Go编程语言(或称--golang),是云计算时代下的C语言,Docker、Kubernetes、Etcd等都是由Golang完成的,经过数年不断的改进,Go语言本身在开发效率和程序运行效率方面又提升了无数个台阶。 Go语言环境搭建 part 1. Win下面环境搭建 : 下载golang,选择windows的版本 ,下载地址 https://studygolang.com/dl 下载完成后,解压到本地目录,然后配置环境...阅读全文
Why are packages imported into file scope instead of package scope? Why is file scope a thing at all?
<p>This really doesn't make sense to me. Go does not let me use a package imported within the same package if the import occurred in another file. However, I am free to use variables between files in a package.</p> <p>This does not make sense to me. I could see eliminating file scope entirely, or reversing the behavior, s...阅读全文
I often see people refer to Go as a new language with a budding ecosystem. What are some projects or libraries that are missing?
<p>I see people complain that Go is still too new or too small. What are some tools/libraries/projects that other languages have that Go is missing? What needs to happen for Go to be considered a language with a robust and thriving ecosystem?</p> <hr/>**评论:**<br/><br/>brokedown: <pre><p>Go is mature and rob...阅读全文
Is Golang a good choice for a CRUD based ReST API?
<p>I'm working on a project that is as the title states. I want to make a ReST API with PostgreSQL as the database. It also uses JWT with Auth0. It seems people recommend net/http + database/sql for web stuff. Have people here had good experiences with projects like these in Go?</p> <p>Also, what do you folder structure ...阅读全文
1. 介绍与安装
1. 介绍与安装 Golang 是什么 Go 亦称为 Golang(按照 Rob Pike 说法,语言叫做 Go,Golang 只是官方网站的网址),是由谷歌开发的一个开源的编译型的静态语言。 Golang 的主要关注点是使得高可用性和可扩展性的 Web 应用的开发变得简便容易。(Go 的定位是系统编程语言,只是对 Web 开发支持较好) 为何选择 Golang 既然有很多其他编程语言可以做同样的工作,如 Python,Ruby,Nodejs 等,为什么要选择 Golang 作为服务端编程语言? 以下是我使用 Go 语言时发现的一些优点: 并发是语言的一部分(并非通过标准库实现),所以编写多线程程序会是一件很容易的事。后续教程将会讨论到,并发是通过 Goroutines 和 channels...阅读全文
新装Linux操作系统后,要保留哪些自启动服务?
和Windows系统一样,Linux服务器运行过程中也会一些没用的软件服务默认运行,这些占用了很多系统资源,也会有安全隐患,所以一般是建议关闭的。那么,工作中Linux主机到底需要有哪些开机自启动服务呢? 新装Linux系统之后,有必要保留的开机自启动服务有5个: Ø sshd:远程连接Linux服务器时要用到,所以必须开启,不然就无法提供远程连接服务了。 Ø rsyslog:日志相关软件,这是操作系统提供的一种机制,系统的守护程序通常会使用rsyslog程序将各种信息写到各个系统日志文件中。 Ø network:系统启动时,如果想激活或关闭各个网络接口的话,可以考虑开启。 Ø crond:用于周期性的执行系统及用户配置的任务计划。有需要时开启。几乎是运维工作中必须要用的一个软件。 Ø sy...阅读全文
编译
Golang 支持交叉编译,在一个平台上生成另一个平台的可执行程序,最近使用了一下,非常好用,这里备忘一下。 Mac 下编译 Linux 和 Windows 64位可执行程序 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go Linux 下编译 Mac 和 Windows 64位可执行程序 CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go Wind...阅读全文
Could I apply this daemon guide to go?
<p>So I've been tinkering with go for the past two weeks and I've been trying to figure out what the easiest way to serve my http server application as a daemon. The search results were pretty much over my head, so I took go out of the picture and came across <a href="https://blog.frd.mn/how-to-set-up-proper-startstop-s...阅读全文
Changes you want for Go 2.0
<pre><code>We need your help. Please tell us how Go is working for you, and more importantly not working for you </code></pre> <p>So it seems that they wanna hear the community, let's make it! Starting from now, let's put here what features would you like for the new version of Go. I want every G...阅读全文
Easiest way to read the input from an USB gamepad crossplatform?
<p>Hi,</p> <p>I would like to know what would be the easyist way to read an USB gamepad with go as input for a little game?</p> <p>It would be nice if the code would run crossplatform ARM Linux and AMD64 Mac OS.. </p> <p>I know there are lib usb binding like <a href="https://github.com/kylelemons/...阅读全文
Using Buffalo binary file (built on Linux) on a Windows Machine
<p>Hello! Has anyone been using the buffalo web framework? If the answer is yes, you might know how to help me. Using Buffalo i've built a a full binary of my application on my Linux enviroment. This binary works across multiple linux distros and MacOS. But when i try to run it on a windows machine, i'm unable to do it. Do i ...阅读全文
Local cross-platform testing ideas
<p>Hi all,</p> <p>I've been working on this project in Go and wanted to figure out someway to run tests cross-platform.</p> <p>Today I committed wrapping 'go test' calls in a 'golang:$tag' docker image. Has anyone else done this? (Or something else) </p> <p><a h...阅读全文
Are apps build with gotk3 self contained?
<p>I'm building an app for linux with gotk3. If I build it with gtk 3.3.20, will it run properly on a system with gtk 3.18? Some CSS parameters like margin doesn't work on gtk 3.3.18. </p> <hr/>**评论:**<br/><br/>Bargalarg: <pre><p>The gotk3 project uses CGO to link to gtk3 libraries on a com...阅读全文
Homebrew Install vs Official Installer
<p>Hello!</p> <p>So I read something on Hackernews about there being some conflict with the way homebrew installs Go vs the official installer. Is this still the case? Can I safely install and use Go via homebrew or am I better off using the official installer? </p> <p>Also, can anyone recommend vim (neovim) plugins ...阅读全文
Using FFI or similar to run Rust code in Go
<p>I'm building an app and the backend preferably would interface with Rust. I could just do that with Rails and FFI but I would much rather the benefit of a statically typed language. Is there a way to do this? I can't seem to find any good documentation online.</p> <p>Thank you!</p> <p>Edit: I belie...阅读全文
Deploying Golang API's. What do?
<p>I was hoping someone here could tell me the best way to deploy golang api's. I am concerned about a panic during runtime and the server shutting down. </p> <p>Does anyone have some life advise for me?</p> <hr/>**评论:**<br/><br/>deusmetallum: <pre><p>Run it in a docker container with -...阅读全文
Go 编程: 那些奇怪的注释
自从上篇总结了一下Go 编程: 交叉编译 vs 条件编译之后,觉得有必要对于类似条件编译标签等特殊注释做一次简单收集。 原文发布于个人站点: GitDiG.com, 原文链接: Go 编程: 那些奇怪的注释 1. 常规注释 每种开发语言都有自己的注释语法和格式,也大多类似。 Go 语言和市面上其它多种高级语言的注释语法也类似,主要有以下两种语法格式: 注释行 以符合 // 开头 注释块 以符号 /* 注释内容 */ 包括 通常情况下, 对外公开的包、函数、常量、变量均需要进行注释。代码是否注释完全,可以通过lint工具进行审查。不了解的话,可以参考像 Awesome-Go 一样提升企业 Go 项目代码质量一文。 但是,以上也就仅仅是正常情况。在很多特殊情况下,一些看似符合以上注释语法的地方,...阅读全文
每天一点GO语言——Linux环境下安装Go语言环境以及编写Go语言程序初体验
每天一点GO语言——Linux环境下安装Go语言环境以及编写Go语言程序初体验 一、安装Go语言环境 [root@localhost opt]# yum -y install wget git [root@localhost opt]# wget -c https://studygolang.com/dl/golang/go1.10.3.linux-amd64.tar.gz [root@localhost opt]# tar -zxvf go1.10.3.linux-amd64.tar.gz [root@localhost opt]# ls go go1.10.3.linux-amd64.tar.gz nginx-1.16.1 rh share_Ubuntu18.04 [root@local...阅读全文
Encrypting files if you know nothing about encryption?
<p>So, i'm sure i'm committing some cardinal sin, but i'm looking to add encryption to a project i'm working on and i know little to nothing about encryption.</p> <p>Specifically, i want the user to be able to provide a file <em>(some type of key file on disk)</em> and it will decrypt b...阅读全文
What is the thing that made you like go?
<p>Was it the syntax? The performance of the language / compiler or something else?</p> <hr/>**评论:**<br/><br/>bastiaanvv: <pre><p>A big plus for me is that Go code is pretty easy to read and understand. I can come back to some code I created years ago and understand how it works in no time at all.</p>...阅读全文
go 的介绍与安装
1. 介绍与安装 Golang 是什么 Go 亦称为 Golang(按照 Rob Pike 说法,语言叫做 Go,Golang 只是官方网站的网址),是由谷歌开发的一个开源的编译型的静态语言。 Golang 的主要关注点是使得高可用性和可扩展性的 Web 应用的开发变得简便容易。(Go 的定位是系统编程语言,只是对 Web 开发支持较好) 为何选择 Golang 既然有很多其他编程语言可以做同样的工作,如 Python,Ruby,Nodejs 等,为什么要选择 Golang 作为服务端编程语言? 以下是我使用 Go 语言时发现的一些优点: 并发是语言的一部分(并非通过标准库实现),所以编写多线程程序会是一件很容易的事。后续教程将会讨论到,并发是通过 Goroutines 和 channels...阅读全文
golang交叉编译
Linux系统下编译Windows64位系统、Mac系统可执行程序 CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build main.go Mac系统下编译Linux系统、Windows64位系统可执行程序 CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build main.go CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build main.go Windows系统下编译Linux系统、Mac系统可执行程序 SET CGO_ENABLED=0 SET GOOS...阅读全文