Coder Social home page Coder Social logo

p0's Introduction

Project 0: Introduction to Go concurrency and testing

Setting up Go

You can download and install Go for your operating system from the official site.

Please make sure you install Go version 1.18. The Gradescope autograder uses Go version 1.18 too.

Using Go on AFS

For those students who wish to write their Go code on AFS (either in a cluster or remotely), first see if Go 1.18.* is already installed:

$ go version
go version go1.18.1 linux/amd64

If not, follow the guidance to download Go for linux here. However, instead of extracting the archive into /usr/local as mentioned in the installation instructions, extract the archive into a custom location in your home folder with following commands:

$ tar -C $HOME/(custom_directory) -xzf go1.18.linux-amd64.tar.gz

Then, instead of adding /usr/local/go/bin to the PATH environment variable as mentioned in the installation instructions, replace /usr/local with the path in which you have extracted the archive in the step before:

$ export PATH=$HOME/(custom_directory)/go/bin:$PATH

You will also need to set the GOROOT environment variable to be the path which you have just extracted the archive (this is required because of the custom install location):

$ export GOROOT=$HOME/(custom_directory)/go

Using Windows for P0

For the students who wish to write their Go code on their local Windows machine, we suggest using Windows Subsystem for Linux 2 (WSL 2) because some of our tests use Linux-specific functions.

Part A: Implementing a key-value messaging system

This repository contains the starter code that you will use as the basis of your key-value messaging system implementation. It also contains the tests that we will use to test your implementation, and an example 'server runner' binary that you might find useful for your own testing purposes.

The below go test commands should work out-of-the-box. If at any point you have any trouble with building, installing, or testing your code, the article titled How to Write Go Code is a great resource for understanding how Go workspaces are built and organized. You might also find the documentation for the go command to be helpful. As always, feel free to post your questions on Edstem as well.

Running the official tests

To test your submission, we will execute the following command from inside the src/github.com/cmu440/p0partA directory:

$ go test

We will also check your code for race conditions using Go's race detector by executing the following command:

$ go test -race

To execute a single unit test, you can use the -test.run flag and specify a regular expression identifying the name of the test to run. For example,

$ go test -race -test.run TestBasic1

Testing your implementation using srunner

To make testing your server a bit easier (especially during the early stages of your implementation when your server is largely incomplete), we have given you a simple srunner (server runner) program that you can use to create and start an instance of your KeyValueServer. The program simply creates an instance of your server, starts it on a default port, and blocks forever, running your server in the background.

To compile and build the srunner program into a binary that you can run, execute the command below from within the src/github.com/cmu440/ directory:

$ go install github.com/cmu440/srunner

Then you can run the srunner binary from anywhere by executing:

$ $HOME/go/bin/srunner

($HOME/go/bin is Go's default destination for go install'd binaries. If the command fails or you want to change the install directory, see the options here.)

The srunner program won't be of much use to you without any clients. It might be a good exercise to implement your own crunner (client runner) program that you can use to connect with and send messages to your server. We have provided you with an unimplemented crunner program that you may use for this purpose if you wish. Whether or not you decide to implement a crunner program will not affect your grade for this project.

You could also test your server using Netcat (i.e. run the srunner binary in the background, execute nc localhost 9999, type the message you wish to send, and then hit enter). You can get more information on how to use netcat using the man pages (man nc).

Part B: Testing a squarer

Once you have written your test, simply run

$ go test

in p0partB to confirm that the test passes on the correct implementation.

Submission

Submit the handin.zip file created by running make handin in src/github.com/cmu440. Do not change the names of the files (server_impl.go and squarer_test.go) as this will cause the tests to fail.

p0's People

Contributors

mweidner037 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.