Go R1 Day 6
Day 6 of 100
- Learned a little on bubble sort algorithm
- Edited aws-go lambda tests
- Used debugger a bit more to look at error return values on failure
Rebuild Dash Index Due to Corrupted Index
I use Dash for improved doc access.
Terraform updated recently to
0.13.x and I began having odd issues with AWS provider results coming through.
If you need to rollback, just go to the preferences and pick an older docset, in my case
0.13.0 worked correctly.
Make sure to remove the problematic version (the uninstall refers to just the most recent, not any additional versions you selected under the dropdown)
If the index doesn’t rebuild, you can close the app, manually remove the index, and it will rebuild on open. I’m pretty sure you don’t need to do this if you use the uninstall option in the dialogue.
On macOS 10.15, you can find the index at
~/Library/Application Support/Dash/Data/manIndex.dsidx and delete this.
Reopen Dash and it will rebuild the index.
Incredible setup experience with gitpod
What a polished setup experience from gitpod. Super impressed as I’ve never seen an interactive terraform setup asking for user input.
This basically generated an entire setup for GitPod, and persisted the Terraform plan for the entire stack it created in a directory for management and adjustments as desired.
I’m seriously impressed.
Check this out at: Install on AWS
Day 5 of 100
- I created my first unit test for go
- It’s a bit interesting coming from a background with PowerShell and Pester as my primary unit test framework. For instance, in Pester you’d declare the anything, but autodiscovery works with
*.tests.ps1, being the normal convention.
- There is no pointer value providing the test package, it’s just other PowerShell calling PowerShell.
- I’m biased I know, but the first test condition being like below seems clunky. I was hoping for something that was more like Pester with
test.Equals(got, want,"Error message")as the syntax is more inline to what I’d expect. I haven’t dived in further so this is just a thought, hoping this is just the newbie 101 test case example and there are more succinct comparison and test methods available.
- Update: Good article explaining the opinionated approach with testing and reasoning not to use assertions located at: Golang basics - Writing Units Tests. This is helpful to someone wanting to learn. I don’t want to force my prior paradigms on the language, because basically the whole reason I decided on Go over python or other language was wanting to learn something that helped me think in a fundamentally different way than using dotnet/Powershell. Python is very similar to PowerShell syntax wise for example, while Go is forcing me to look at things from a completely different view.
- I’ll stick with the default package while I’m learning. However, there is a package called Testify that is worth exploring if I find I still want assertions later on.
Day 4 of 100
- In the last week some more Pluralsight Go (Nigel’s courses are always stellar)
- I’ve done some odd work as had time in between last update, but nothing structured. Might continue with
learn-go-with-testsbut also came across exercism and might tackle that soon as well.
- Setup new project in Visual Studio Codespaces
- Used Serverless Framework to generate
aws-go-sdkresources for AWS SSM Secrets Manager
- Grabbed SSM Secrets manager output and used to create a POST request for authorization token
- Used DumpRequest to pretty print output for debugging purpose
- Hung my head in shame at my copy pasta project 😀
- Realized half of the battle is just getting my lambda debugging effort running locally. Not exactly the easiest starter project.
- Need to master different request types. PowerShell makes this easy with Invoke-RestMethod and object construction. I found that the
Postmethod wasn’t appropriate as I wanted to control custom headers. This required me to use a different approach, which I ended up doing with
- Not sure in a Go Playground sample to test and echo a post request. Thinking if no service that does this might try creating a Go routine to accept the request locally and echo for the purpose of a demo. Any suggestions welcome.
- Identified i really need better understanding of the godoc libraries as would help a lot. Vscode intellisense even in codespaces isn’t performing great, so I’m not getting that help that would really expedite discovery as a beginner. I might give my EAP Goland install a try and see if it helps.
- Successfully included
- Successfully submitted request for authorization token and got response back into a struct, something that as a newbie I found a major win 🎉 using
arreferring to a pointer another win for me as new to pointers) being passed in like below:
Day 3 of 100
- Learned about GOROOT, GOPATH and how to configure
- Ran into problems with Visual Studio code reporting:
- After attempting solution with various profile files, I tried setting the setting:
settings.jsonand this resolved the issue.
- After it recognized this, I ran the
Go: Current GOPATHfrom the command palette and it found it.
- Finally, after this it reporting back some feedback showing it was recognizing the latest version I was running.
- Initialized a new serverless framework project for
aws-go-modtemplate using the following command:
serverless create --template aws-go-mod --path ./sqlserverand the initial project layout was created.
- I’m sure this will need to be improved as I go along, but since macOS failed on the go path setup, this resolved my problems for now.
cmd+=results in zooming to 120%,145%,170%
cmd+-results in zooming out to 85%, 70%, 60%
simple conditional flag in terraform
Sometimes, you just need a very simple flag for enabled or disabled, or perhaps just a resource to deploy if
var.stage == "qa".
This works well for a single resource as well as collections if you provide the splat syntax.
Day 2 of 100
- Focused on logistics, setup for remaining tests
- Forked Learn Go With Tests
- Setup Visual Studio Codespaces (Docker Workspace) for isolating this work
- Codespaces default container + Added pwsh as default prompt
TIL: What I’ve been calling the backtick 👉 ```` 👈 for years, is technically the grave accent.
setting default open with on macOS
It should be easy to pick a default program to open a file. On macOS, I was surprised at how poor the design was. Seriously, how is this intuitive?
Open With >
Set this as default. Apparently this only set it for an individual file. This means, every different
csv file required me to do this again.
Instead, I had to
Get Info >
Unlock settings and then choose the default
Open With setting, and further select
Use this application to open all documents like this.
I enjoy most of my development experience with macOS.
Don’t try and tell me that it is the pinnacle of usability though, some of this stuff is just quirky and over complicated. In what world, should my default behavior be set on a specific file and not the the file type?
Day 1 of 100
learning-go-with-teststo ensure a nice structured start, even though I’ve already done
- Setup fresh
gotoolsupdates - Ran golangci-lint through docker to ensure improved linting options ready for further tests
- Fixed default debug template in vscode to use workspacefolder instead of file directory. Strange that it defaulted to the wrong path.
PowerShell has some functionality that can help in pre-processing data by grouping and aggregating.
If you are using
ImportExcel this might be useful to pre-aggregate the results prior to an Excel workbook.
If you are working with PowerShell and needing to do some quick measurement of objects, maybe this will be useful.
Windows users, nice little win for making the great git-town tool even more accessible. 🎉
- install scoop:
iwr -useb get.scoop.sh | iex
scoop install git-town
This is one of my favorite tools for git workflow. If you use GitHub flow to keep a simple workflow, it’s a life saver.
For example, on a branch and need to start a new bit of work to keep your commits atomic?
switch to master > stash pending work > pull latest with rebase > create new branch > push branch to remote OR
git town hack feat/tacos. Need to squash commits and ship to master?
git town ship What about prune all those remote branches that have been merged?
git town prune-branches This is one of my favorite git productivity tools (and it’s written in Go 👍 so cross platform and fast)
Visual Studio Code has a pretty great way to browse through themes by just selecting installed themes and using arrow keys to preview without apply. However, browsing those themes isn’t quite so good, as you need to install to see the changes.
After using Windows versions of launchers that tried to emulate Alfred, I finally took the plunge and bought Alfred’s Powerpack. The buyer remorse of paying > $60 on a “shortcut” app hasn’t really set in as I’m seeing such a wealth of great features that I think the gains as a developer and shortcut aficionado will be well worth the cost in my workflow. So far, highly recommend. The best part for me is the easy plugging in of bash/pwsh scripts to execute on demand for quick productivity tasks without having to navigate and open it up in the terminal.
Here’s a cool way to visualize runspaces and how they work asynchronously.
The random delay can help show how some tasks finish out of order. For example, running that might result in this in the console:
Set an environment variable
export DOCKER_BUILDKIT=1 to enable a much cleaner Dockerfile output when you don’t need verbose debug level information. Reference: Buildkit
brew install micro resulted in my finding what I think will be my new go to cli editor. Very impressed so far. I’ve got too many things to learn to be fluent in vim, and this cross platform cli tool might be my new best friend for more command line-fu. Micro
- add dev container configuration for Go project in Visual Studio code
- Added docker compose file
- Add SQL Server to compose as another service.
docker-compose up -d
- Attach to running container in VSCode
- Magic ⚡
Now I can open Visual Studio Code and run a go project against SQL Server, and tear it all down as I want. Gonna definitely blog on this, as it’s super cool to see this work so well.
While Docker has a steep learning curve, being able to have a full clean dev test environment with SQL Server in a local container and another Ubuntu container to run Go projects in absolutely amazing, not to mention working “inside it” with Remote Workspaces extension from Microsoft.