Debug Golang applications: LLDB

Even that ease and simplicity of using go are one of its main advanatages, there are difficulties in debugging applications written in go. The lack of mature tools (like supported vim plugin) push most of us to use logging techniques to inspect and track down issues. In this article, I will demonstrates how you can use vim and lldb to debug a go application. Before that you should make the application capable for debugging....

August 1, 2015 · 3 min · Svetlin Ralchev

SSH tunneling in Golang

In my previous post, I illustrated the basic usage of ssh package. In this article I will demonstrate how we should use it to implement SSH tunneling. We will forward connection to localhost:9000 through example.com:22 to localhost:8080. The tunneling protocol allows a network user to access or provide a network service that the underlying network does not support or provide directly. We have four actors in this scenario: client - the client that needs resource from remote server local server - a server accessible by the client intermediate server - a server accessible by the local server and remote/target server remote/target server - a server running behind the intermediate server network Each of this server endpoints can be represented by the following struct:...

July 26, 2015 · 3 min · Svetlin Ralchev

SSH Client connection in Golang

SSH is a network protocol for establishing a secure shell session on distant servers. In Golang the package godoc.org/golang.org/x/crypto/ssh implements SSH client and SSH server. In this article, we are using SSH client to run a shell command on a remote machine. Every SSH connection requires an ssh.CleintConfig object that defines configuration options such as authentication. Authentication Options Depending on how the remote server is configure, there are two ways to authenticate:...

July 18, 2015 · 4 min · Svetlin Ralchev

Golang: Pipes and redirection in command line applications

Powerful features of the Linux command line shell are redirection and pipes that allow the output and even input of a program to be sent to a file or another program. In this article, I will demonstrates how we can pipe a file into a go application. Pipes Pipes allow you to funnel the output from one command into another where it will be used as the input. We should use | symbol to redirect the output....

July 11, 2015 · 2 min · Svetlin Ralchev

Golang: Using user defined type as flag in terminal applications

As we saw in the previous article the flag package gives us flexibility to develop command-line applications that suite our needs. In this post, I will show how you can develop a flag argument for user defined type. Lets develop application that should be executed in the following ways: healthcheck -url=http://www.example.com,http://mail.example.com/inbox healthcheck -url=http://www.example.com -url=http://mail.example.com/inbox We can use the predefined url.URL struct in net/url package as type of the arguments that are expected....

July 6, 2015 · 2 min · Svetlin Ralchev