Building Development Environment for Go Lang

After coming back to the Go Lang programming after long break, I encounter a lot of issues like IntelliSense, debug, code navigation doesn’t work. The lining result is different with CI and my local machine. So I re-think about the development environment for Go Lang with my mac.

Go Versioning

The root cause of the weird behaviors were the version of go lang and tools. I’d like to choose the version depend on the project. In this case, we have some cool tools.

anyenv

anyenv helps us to install **env implementation. I can install goenv directory, however, if you want to use others like rubyenv , anyenv might handy.

$ brew install anyenv
$ anyenv init
$ anyenv install --init
$ anyenv install goenv
$ exec $SHELL -l

goenv

If you want to switch the version of the Go, you can user goenv . You can switch and install any go versions.

$ goenv install 1.12.12
$ echo 'export GOENV_ROOT="$HOME/.goenv"' >> ~/.zshenv
$ echo 'export PATH="$GOENV_ROOT/bin:$PATH"' >> ~/.zshenv
$ exec $SHELL -l 
$ goenv versions
goenv versions
  system
  1.12.12
* 1.13.1 (set by /Users/ushio/.anyenv/envs/goenv/version)
$ goenv local 1.12.12 // the command creates .go-version on current dir. You can use global for global settings.
$ go version
go version go1.12.12 darwin/amd64

Directory Structure

Go directory structure has very deep directory structure under $GOPATH . My current directory structure is

/Users/ushio/dev/go/src/github.com/microsoft/<project_name>

$GOPATH is /Users/ushio/dev/go . In my .zshrc

export GOPATH="/Users/ushio/dev/go"
export PATH="$GOPATH/bin:$PATH"

ghq

Sometimes, you might feel that it is painful to go to the ohter go project directory. In this case, ghq is useful.

$ brew install ghq

Before cloning target project, you can go to the directory.

$ cd /Users/ushio/dev/go/src/github.com/microsoft
$ ghq get git@github.com:microsoft/terraform-provider-azuredevops.git

Set the source directory that is managed by ghq.

git config --global ghq.root /Users/ushio/dev/go/src

This tool manage the go projects of yours.

$ ghq list
github.com/microsoft/terraform-provider-azuredevops
    :

To clone a different directory, you just go to the target directory and clone it by git clone This is the example for clone fork repository (TsuyoshiUshio/terraform-provider-azuredevops), but want to clone under (microsoft/terraform-provider-azuredevops). ghq can detect this project.

$ cd /Users/ushio/dev/go/src/github.com/microsoft
$ git clone git@github.com:TsuyoshiUshio/terraform-provider-azuredevops.git

peco

Peco is an interactive filtering tool. With ghq it is very useful to move other projects.

$ brew install peco

Add this script to your .zshrc . This script is taken from a cool blog post.

function peco-src () {
  local selected_dir=$(ghq list -p | peco --query "$LBUFFER")
  if [ -n "$selected_dir" ]; then
    BUFFER="cd ${selected_dir}"
    zle accept-line
  fi
  zle clear-screen
}
zle -N peco-src
bindkey '^]' peco-src

Hit control + ] You can select the target project, then it goes to the target directory from anywhere.

This is image title

Enable Debugging for Unit/Acceptance Testing, and binary

I assume you are using VSCode. You need to install Go extension. For more details. See here.

VSCode with Go extension

Go to the target directory then open VSCode.

$ code . 

Go to the VSCode, then type Command + Shift + p select Go install /update tools Select all tools to update. All tools installed to the target $GOPATH/bin directory. Old version’s tool causing a lot of problem. Be careful if you are using the same versions with others and CI.

This is image title

tools.go

If you want to use the same version for go tools and using Go Module, you can use tools.go strategy. You can refer this page for more details. This is an example for manage stringer. You can add others.

// +build tools

package tools

import (
	_ "golang.org/x/tools/cmd/stringer"
)

Now you can have the IntelliSense, code navigation, and document so on. Old version could cause a problem. Double check the version. (I did. )

This is image title

Unit/Acceptance Test with Debugging

Add .vscode/launch.json on your project.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Acceptance test",
            "type": "go",
            "request": "launch",
            "mode": "test",
            "program": "${workspaceRoot}/azuredevops/resource_project_test.go",
            "args": [
                "-test.v",
                "-test.run",
                "TestAccAzureDevOpsProject_CreateAndUpdate"
            ],
            "envFile": "${workspaceRoot}/.vscode/private.env",
            "showLog": true
        }
    ]
}

NOTE: The launch.json doen’t paste correctly. I add the gist link in here.

Also, write .vscode/private.env for setting Environment Variables for testing.

DEV_ROOT=/Users/ushio/dev/go
GOPATH=/Users/ushio/dev/go
AZDO_ORG_SERVICE_URL="https://dev.azure.com/<YOUR ORGANIZATION>"
AZDO_PERSONAL_ACCESS_TOKEN="<YOUR_AZDO_PERSONAL_ACCESS_TOKEN>"
AZDO_GITHUB_SERVICE_CONNECTION_PAT="<YOUR_GITHUB_SERVICE_CONNECTION>"
AZDO_TEST_AAD_USER_EMAIL=<YOUR_E_MAILS>
TF_ACC=1

Debug works.
This is image title

Tip

You might see could not launch process: decoding dwarf section info at offset 0x0: too short. In my case, after update the all go tools above, restart of VSCode is required. Then it has gone. I also see it when it uses old version.

Binary Debugging

You might want to debug actual binary. In this case, Configure settings.json like this below. You can attach the debugger to a process.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Attach to local process",
            "type": "go",
            "request": "attach",
            "mode": "local",
            "processId": 87235
        },
    ]
}

Then modify code. We need time to attach debugger, so you can add some code to wait for a while in somewhere in your code.

time.Sleep(60 * time.Second())

When you compile add this flag. This flag means do not optimize code when compile it. It required to attach the debugger.

$ go build -gcflags="all=-N -l"  github.com/TsuyoshiUshio/foo/cmd/foo

Then run the app.

$ ./foo 

Then at the another terminal, see the process number.

$ ps
  PID TTY           TIME CMD
  481 ttys000    0:00.16 /Applications/iTerm.app/Contents/MacOS/iTerm2 --server login -fp ushio
  486 ttys000    0:03.26 -zsh
87235 ttys000    0:00.01 ./foo
73543 ttys002    0:06.97 /bin/zsh -l
24077 ttys004    0:00.60 -zsh
86796 ttys005    0:00.54 /bin/zsh -l

then modify the launch.json with change the processId as the target process. This case is 87235 . Then start debug on your VSCode.

Environment Variables for integrated terminal

I wanted to add Environment Variables for VSCode terminal. It depends on a project. Go to Preferences > Settings then click Workspace and search terminal.integrated.env You will find Edit in settings.json link. You can configure this settings both on global (User) and local on your workspace (Workspace). In case of workspace, you will see .vscode/settings.json in your workspace.

This is image title

Click the link. You will see the .vscode/settings.json Add Environment Variables section like this.

 "terminal.integrated.env.osx": {
        "AZDO_ORG_SERVICE_URL":"https://dev.azure.com/<YOUR_ORG>",
        "AZDO_PERSONAL_ACCESS_TOKEN":"<YOUR_AZDO_PAT>",
        "AZDO_GITHUB_SERVICE_CONNECTION_PAT":"<YOUR_GITHUB_PAT>",
        "AZDO_TEST_AAD_USER_EMAIL": "<EMAIL_FOR_TEST>"
    },

Conclusion

Now, I’m satisfy the development environment settings for me. Enjoy coding with Go Lang.

Thanks for reading !

This article has been originally written by Tsuyoshi Ushio at medium.com

#go #golang #developers

What is GEEK

Buddha Community

Building Development Environment for Go Lang
Fredy  Larson

Fredy Larson

1595059664

How long does it take to develop/build an app?

With more of us using smartphones, the popularity of mobile applications has exploded. In the digital era, the number of people looking for products and services online is growing rapidly. Smartphone owners look for mobile applications that give them quick access to companies’ products and services. As a result, mobile apps provide customers with a lot of benefits in just one device.

Likewise, companies use mobile apps to increase customer loyalty and improve their services. Mobile Developers are in high demand as companies use apps not only to create brand awareness but also to gather information. For that reason, mobile apps are used as tools to collect valuable data from customers to help companies improve their offer.

There are many types of mobile applications, each with its own advantages. For example, native apps perform better, while web apps don’t need to be customized for the platform or operating system (OS). Likewise, hybrid apps provide users with comfortable user experience. However, you may be wondering how long it takes to develop an app.

To give you an idea of how long the app development process takes, here’s a short guide.

App Idea & Research

app-idea-research

_Average time spent: two to five weeks _

This is the initial stage and a crucial step in setting the project in the right direction. In this stage, you brainstorm ideas and select the best one. Apart from that, you’ll need to do some research to see if your idea is viable. Remember that coming up with an idea is easy; the hard part is to make it a reality.

All your ideas may seem viable, but you still have to run some tests to keep it as real as possible. For that reason, when Web Developers are building a web app, they analyze the available ideas to see which one is the best match for the targeted audience.

Targeting the right audience is crucial when you are developing an app. It saves time when shaping the app in the right direction as you have a clear set of objectives. Likewise, analyzing how the app affects the market is essential. During the research process, App Developers must gather information about potential competitors and threats. This helps the app owners develop strategies to tackle difficulties that come up after the launch.

The research process can take several weeks, but it determines how successful your app can be. For that reason, you must take your time to know all the weaknesses and strengths of the competitors, possible app strategies, and targeted audience.

The outcomes of this stage are app prototypes and the minimum feasible product.

#android app #frontend #ios app #minimum viable product (mvp) #mobile app development #web development #android app development #app development #app development for ios and android #app development process #ios and android app development #ios app development #stages in app development

Mitchel  Carter

Mitchel Carter

1602979200

Developer Career Path: To Become a Team Lead or Stay a Developer?

For a developer, becoming a team leader can be a trap or open up opportunities for creating software. Two years ago, when I was a developer, I was thinking, “I want to be a team leader. It’s so cool, he’s in charge of everything and gets more money. It’s the next step after a senior.” Back then, no one could tell me how wrong I was. I had to find it out myself.

I Got to Be a Team Leader — Twice

I’m naturally very organized. Whatever I do, I try to put things in order, create systems and processes. So I’ve always been inclined to take on more responsibilities than just coding. My first startup job, let’s call it T, was complete chaos in terms of development processes.

Now I probably wouldn’t work in a place like that, but at the time, I enjoyed the vibe. Just imagine it — numerous clients and a team leader who set tasks to the developers in person (and often privately). We would often miss deadlines and had to work late. Once, my boss called and asked me to come back to work at 8 p.m. to finish one feature — all because the deadline was “the next morning.” But at T, we were a family.

We also did everything ourselves — or at least tried to. I’ll never forget how I had to install Ubuntu on a rack server that we got from one of our investors. When I would turn it on, it sounded like a helicopter taking off!

At T, I became a CTO and managed a team of 10 people. So it was my first experience as a team leader.

Then I came to work at D — as a developer. And it was so different in every way when it came to processes.

They employed classic Scrum with sprints, burndown charts, demos, story points, planning, and backlog grooming. I was amazed by the quality of processes, but at first, I was just coding and minding my own business. Then I became friends with the Scrum master. I would ask him lots of questions, and he would willingly answer them and recommend good books.

My favorite was Scrum and XP from the Trenches by Henrik Kniberg. The process at D was based on its methods. As a result, both managers and sellers knew when to expect the result.

Then I joined Skyeng, also as a developer. Unlike my other jobs, it excels at continuous integration with features shipped every day. Within my team, we used a Kanban-like method.

We were also lucky to have our team leader, Petya. At our F2F meetings, we could discuss anything, from missing deadlines to setting up a task tracker. Sometimes I would just give feedback or he would give me advice.

That’s how Petya got to know I’d had some management experience at T and learned Scrum at D.

So one day, he offered me to host a stand-up.

#software-development #developer #dev-team-leadership #agile-software-development #web-development #mobile-app-development #ios-development #android-development

Christa  Stehr

Christa Stehr

1594456938

Offshore Software Development - Best Practices

With the rise of globalization and the worldwide lockdown due to the pandemic, most of the work has been done by remote working processes and professionals from their homes. This lockdown has proved the efficiency of remote development and enhanced the trust in offshore software development industry.

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development. This is why you should read this guide for the best practices when hiring an offshore software development company. Despite the size and the industry of the business, offshore software development is not beneficial for every entrepreneur in many aspects to make the optimum use of talents in technology across the globe.

Here are some of the top reasons why offshore development is beneficial for your business.

  • Offshore development teams can work on flexible timing to provide you with the best possible software development practices.
  • Get access to the talents across the world from your home to develop the top of the line software with the help of offshore development companies.
  • Assured high quality and next-generation technology expertise with duly NDA signed with respect to the priorities of the business.
  • With flexible recruitment models, you can hire the freelance developers, remote development team, or an entire offshore development company with respect to the size of your business.
  • Build high-end software applications from one corner of the world by hiring software developers across the world.
  • Get immediate access to the best resources without hiring them on a permanent basis.

To avail of all these benefits, you should have clear goals, a list of requirements, and features that are mandatory for your software product.

Here are a few tips to help you find the best offshore software development company. Build a top-notch software application by following the listed best practices.

#web development #how to start offshore software development company #offshore meaning #offshore software development best practices #offshore software development company #offshore software development company in india #offshore software development cost #offshore software development statistics #outsource software development

Hire Dedicated Golang Developers | Golang Web Development Company

Does your business need a robust system across large-scale network servers then developing your app with a Golang programming language is the way to go. Golang is generally used for the development of highly secured, High Speed and High Modularity apps such as a FinTech Industry.

Want to develop a Highly secured app for your business?

Then hire a dedicated Golang developer from WebClues Infotech that are highly skilled in carrying out the work in a timely and qualitative output. With WebClues Infotech you get the assurance that we know what are the customers’ expectations and how to deliver on them on time.

Get your desired Golang Developer based on your project requirement!!

Share your requirements here https://www.webcluesinfotech.com/contact-us/

Book Free Interview with Golang developer: https://bit.ly/3dDShFg

#hire golang developer #hire go language developer #dedicated golang app developers #golang web development company #hire golang developers india #hire expert golang developers

navin prakash

1609314430

Why Use the Go Language for Your Project?

Golang is a language for open-source programming. It’s typed automatically and generates binaries of compiled computer language. Developers claim that when it comes to syntax, the Go language of Google is the C for the twenty-first era. At present, Go Lang Training in Chennai is very useful to operate in coding language. This new programming language, however, includes tools that enable you to be using memory securely, handle objects, pick up garbage, as well as provide strict typing along with competition.
Advantages of using Go for your project:
Go provides a whole range of benefits. The language started to evolve nearly as soon as it was published back in 2009. It rapidly began to drift from the language of #65 to the important jobs around the globe. Company Insider then named Go the 2016 hottest programming language. Maybe you want to know why Go is on the rise. The explanation is that Go has the same efficiency as C and is much easier to manage than Java, so we don’t need a virtual machine, no warm-up time, no JAR hell, etc. Let’s take a look at the other benefits provided by Golang.
Spend less time and money to create an application
If you’re using Go for your project, you don’t need a big teak stack. In reality, applications generated in Go compile to native machine code and do not require an interpreter or virtual machine. This also implies that Go apps are going to work faster and will not need the warm-up we just described.
Use Go for a range of applications
Go is a very versatile language, capable of solving many problems. It can be used for coding of devices and services, big data, machine learning, sound / visual editing.
Get more production for your application and a broader audience
Go is a compiled language similar to C or C++ and doesn’t need any interpretation. Correspondingly, the absence of an interpreter frees up that power and provides more output to a Go-built app, which users would certainly enjoy. Besides, Go knows how to control the allocated memory correctly.
Another great news is that in terms of device specifications, a Go-based application is less challenging. For users of older computers, this is good as they will still get to enjoy your application. And with more users that use the device, you’re going to get more cash.
Worry less about the app crashing
To use the maximum potential of different processes, Go was developed. In addition, the language can use all the processor resources correctly, so it is great as a single method for operating an app in the background. Thanks to goroutines, that are used instead of loops and need far less RAM because of their non-system loop existence, this is possible. This is why the risk of crashing a Go app is lower due to lack of storage.
Easily find Go developers for your project
It’s blowing up Go. If you look at Stack Overflow’s developer survey, you can see that Go has been one of the top five most loved and most needed languages. So Go Lang Course in Chennai is very useful to develop your career in the IT industry. Evermore experts are plunging into the world of Go. In the coming years, you’ll expect to find even more specialists to create and manage your Go-based application.

#go lang course in chennai #go lang training in chennai #go #lang #golang #training