A port of Rebecca Murphey's js-assessment for Go

go-assessment

Your Job Is To Make The Tests Pass!

What is this?

This is a tool for assessing or practicing beginner level programming in Golang. It is inspired by Rebecca Murphey's js-assessment

A while back I tried out Murphey's js-assessment and found it to be a valuable tool for refreshing my javascript capability when I had not written any JavaScript for a few months. I figured a similar tool for Go might be useful for the same reason.

This tool leads the user through a series of Go implementation exercises from easy to medium. It's not meant to be a leetcode challenge. The point is to exercise your skill with some basic syntax and semantics of Go. Most of the tests and implementations are straightforward. A few are harder, require a bit of algorithm knowledge or the ability to look up a solution. If you have gone through the official golang tutorial you will know enough to make most of the tests pass. For the rest go ahead and look up a solution if you need to. Feel free to use go standard libraries. No need to reinvent the wheel.

This tool relies on Test Driven Development using the native Go test framework. The ./app directory contains a set of test files (app/topic_test.go) and a corresponding app skeleton file (app/topic.go) with the required function definitions but missing the implementations. Treat the topic_test.go files as the specifications for the function skeletons. The goal is to provide the implementations in the skeleton files to pass the tests. If the tests are not passing, dig into the topic_test.go files to figure out what the requirement is, then fix the skeleton file so the tests pass. You are done when all tests pass. You should not have to modify anything in the topic_test.go files, only the topic.go skeleton files (unless the tests have a bug in which case feel free to report it).

  • if you are stuck, don't hesitate to get help. Look it up!
  • if you have a compile error in a function under test (inside one of the topic.go files) it will terminate the tests for that topic. You will (probably) get an error message describing where and what the compile error is.

The tests are ordered (more or less) by increasing difficulty. The topics covered include

  • Operators
  • Flow Control
  • Strings
  • Slices
  • Binary
  • Functions
  • Recursion
  • Methods
  • Regexp
  • Async

Here's how to work this:

  1. Set up Go
  2. Clone or fork this repo
  3. Start the browser based test framework (test_browser.sh or test_browser.cmd). Open a browser to the host:port (:8080 by default)
  4. Refresh the page to run the tests
  5. Update the skeleton files in ./app
  6. When all tests pass you are done

Running the Tests

To run the tests and see their results you have some choices.

  1. From a web browser : best
    • the tool includes a web server implementation that will run the tests and display the results for you.
      • in the root of the repo, run './test_browser.sh' (or 'test_browser.cmd' on Windows. see the issue regarding Windows Antivirus if you have problems) and connect to the hostip:8080 with a browser. You will get a display of all the test results.
      • after editing skeleton files, you can update the test results by refreshing the web page. this will rerun the tests and update the results.
      • you don't need to restart the web server when you change a function under test. just refresh the page. If you modify a topic_test.go file, you would need to restart the server.
    • the browser tool needs to be connected to the internet because it uses Bootstrap from a CDN. If you want to run locally you can download the required bootstrap files and modify './static/index.html' to point to their local copies.
    • You can change the port number in './main.go' or in the startup scripts.
  2. From the Shell
    • run a shell script that runs all the tests and writes the output to 'results.txt'
      • for Linux or Mac, the script is './test_all.sh'
      • for Windows, the script is 'test_all.cmd'
        • if your tests and other go programs build slowly on Windows, its probably due to Windows Defender or other antivirus
    • you can run individual test files using 'go test...'
      • example for the strings test
      • [linux/macos]: 'go test -v ./app/strings*.go ./app/test_util.go ./app/app_types.go'
      • [windows]: 'go test -v ./app/strings.go ./app/strings_test.go ./app/test_util.go ./app/app_types.go'

Debugging the functions under test

  1. Visual Studio Code (Or other debugger with similar capability)

Visual Studio Code set up for Go programming provides the capability to run individual tests and use breakpoints and other debugger functions.

With this setup, you can run individual tests within the topic_test.go functions. VS Code will superimpose buttons at the top of each test to let you run or debug the test function. This allows you to step into the actual function under test and observe it. You should never have to change anything in the topic_test.go function itself.

This is independent of whether or not the browser test setup is running. You can do both at the same time. If you are viewing the browser based test output while editing with VS Code and you need to debug a specific test, you can use the VS Code test debug function and still update results with a browser refresh

  1. Logging output in a function under test

If you want to debug using printouts from within a function under test, the testutil.go file provides the _testLog(s string) function. You can print output using testLog from within a function in an app skeleton file. Due to the way the golang testing system works, the output from these logs may come after the results for that test are printed. The log output specifies the file and line number of where the testLog was called.

Go Modules

This code is set up to be using Modules rather than GOPATH. As it is, it does not import or use any modules besides standard Go libraries. You could probably fix it to use GOPATH if you require that.

Owner
david howard
Sitting in the snow somewhere near Ankara Turkey
david howard
Similar Resources

A Go port of Ruby's dotenv library (Loads environment variables from `.env`.)

GoDotEnv A Go (golang) port of the Ruby dotenv project (which loads env vars from a .env file) From the original Library: Storing configuration in the

Jan 5, 2023

Port of LZ4 lossless compression algorithm to Go

go-lz4 go-lz4 is port of LZ4 lossless compression algorithm to Go. The original C code is located at: https://github.com/Cyan4973/lz4 Status Usage go

Jun 14, 2022

Port of Google's Keyczar cryptography library to Go

Important note: Keyczar is deprecated. The Keyczar developers recommend Tink. This is a port of Google's Keyczar library to Go. Copyright (c) 2011 Dam

Nov 28, 2022

Port of webcolors library from Python to Go

go-webcolors A library for working with color names and color value formats defined by the HTML and CSS specifications for use in documents on the Web

Sep 26, 2022

Port of D. J. Bernstein's primegen prime number generator to Go

primegen primegen is a Go package that generates prime numbers in order using the Sieve of Atkin instead of the traditional Sieve of Eratosthenes. It

Jul 20, 2021

Golang port of Petrovich - an inflector for Russian anthroponyms.

Golang port of Petrovich - an inflector for Russian anthroponyms.

Petrovich is the library which inflects Russian names to given grammatical case. This is the Go port of https://github.com/petrovich. Installation go

Dec 25, 2022

A Go port of the Rapid Automatic Keyword Extraction algorithm (RAKE)

A Go implementation of the Rapid Automatic Keyword Extraction (RAKE) algorithm as described in: Rose, S., Engel, D., Cramer, N., & Cowley, W. (2010).

Nov 23, 2022

Go port of Coda Hale's Metrics library

go-metrics Go port of Coda Hale's Metrics library: https://github.com/dropwizard/metrics. Documentation: http://godoc.org/github.com/rcrowley/go-metri

Dec 30, 2022

Go binding to libserialport for serial port functionality.

Go Serial Package serial provides a binding to libserialport for serial port functionality. Serial ports are commonly used with embedded systems, such

Nov 1, 2022

Port of the lemon parser generator to the Go programming language

From the golang-nuts mailing list (with few modifications): --== intro ==-- Hi. I just want to announce a simple port of the lemon parser generator

Feb 17, 2022

An experimental port of TinyRb to Google go, both as a means of learning go and exploring alternate approaches to implementing Ruby. Work is currently focused on the GoLightly VM.

tinyrb¶ ↑ A tiny subset of Ruby with a Lua'esc VM. Everything in TinyRb should run in the big Ruby. (except bugs and things that don't comply to the p

Sep 22, 2022

Interact with Chromium-based browsers' debug port to view open tabs, installed extensions, and cookies

Interact with Chromium-based browsers' debug port to view open tabs, installed extensions, and cookies

WhiteChocolateMacademiaNut Description Interacts with Chromium-based browsers' debug port to view open tabs, installed extensions, and cookies. Tested

Nov 2, 2022

A go port of numpy-financial functions and more.

go-financial This package is a go native port of the numpy-financial package with some additional helper functions. The functions in this package are

Dec 31, 2022

grobotstxt is a native Go port of Google's robots.txt parser and matcher library.

grobotstxt grobotstxt is a native Go port of Google's robots.txt parser and matcher C++ library. Direct function-for-function conversion/port Preserve

Dec 27, 2022

Router socks. One port socks for all the others.

Router socks. One port socks for all the others.

Router socks The next step after compromising a machine is to enumerate the network behind. Many tools exist to expose a socks port on the attacker's

Dec 13, 2022

Port of perl5 File::RotateLogs to Go

file-rotatelogs Provide an io.Writer that periodically rotates log files from within the application. Port of File::RotateLogs from Perl to Go. SYNOPS

Jan 9, 2023

Simple HTTP tunnel using SSH remote port forwarding

Simple HTTP tunnel using SSH remote port forwarding

Nov 18, 2022

A fully self-contained Nmap like parallel port scanning module in pure Golang that supports SYN-ACK (Silent Scans)

gomap What is gomap? Gomap is a fully self-contained nmap like module for Golang. Unlike other projects which provide nmap C bindings or rely on other

Dec 10, 2022
Comments
  • Windows Antivirus problems with Go

    Windows Antivirus problems with Go

    Many third party anti-virus for windows will block builds of go executables. This is independent of this application. The tests seem to run properly under Windows Defender.

    If you are running FSecure and you run the browser based tests, the tests hang with no indication. The page will eventually fail to load.

A port of Namespaces are used to separate different curves

Description Namespaces are used to separate different curves. So for example to support both ED25519 and the NIST P256 curves, one could import into a

Feb 4, 2022
Kubei is a flexible Kubernetes runtime scanner, scanning images of worker and Kubernetes nodes providing accurate vulnerabilities assessment, for more information checkout:
Kubei is a flexible Kubernetes runtime scanner, scanning images of worker and Kubernetes nodes providing accurate vulnerabilities assessment, for more information checkout:

Kubei is a vulnerabilities scanning and CIS Docker benchmark tool that allows users to get an accurate and immediate risk assessment of their kubernet

Dec 30, 2022
Coding assessment to create Todo app given by Percipia

Coding assessment to create Todo app given by Percipia

Oct 20, 2021
Assessment challenge for tuimusement

TUI Musement Assessment Challenge Based on this Gist I created the following solution. Installation The repository already contains the external packa

Dec 1, 2021
This is Reperio Health's GoLang backend assessment

reperio-backend-assessment This is Reperio Health's GoLang backend assessment. N

Dec 22, 2021
Myretail-target-case-study - Case study assessment for Target.com

myRetail This project contains two solutions to the Target myRetail case study. The prompt is copied over to PROMPT.md for convenience, but the TLDR i

Jan 1, 2022
Savoir - A tool to perform tasks during internal security assessment

Savoir Savoir is a tool to perform tasks during internal security assessment. Th

Nov 9, 2022
Iphelper - Cyderes/Fishtech golang assessment

Cyderes/Fishtech golang assessment iphelper: IP enrichment serverless function f

Jan 24, 2022
A little websocket TCP proxy to let browsers talk to a fixed port on arbitrary hosts. Built for Gemini (gemini://, port 1965)

Kepler A little websocket TCP proxy built to let Amfora talk to Gemini servers when running in a browser. Usage $ git clone https://github.com/awfulco

May 27, 2022
Port-proxy - Temporary expose port for remote connections

Port proxy util Temporary expose port for remote connections. E.g. database/wind

Jan 27, 2022