Skip to main content

Featured

Week 12: Release 0.4 Part: 3

Release 0.4 Part 3 This is going to be my final post for this class which covers my final update on my Release 0.4. Earlier this week I made a PR that ports SearchBar to NextJS but I'm still waiting for it to be reviewed some more. I've had some feedback that I have implemented and have also requested a review again. Overall this Release went pretty smoothly for the actually GitHub side of things like setting up the issue, making the PR, and so on. In Release 0.3 I wasn't so certain on how this process happened with Telescope, but now I never had these issues for 0.4. Issue #1470 Fix #1470: Port SearchBar from Gatsby -> NextJS #1503 Did I Meet My Goals? Going into this release I had two main goals: 1. Setup the Issue/PR with no issues 2. Learn about NextJS I feel like I meet both of these goals at the end. I had no issues setting up my branch, updating my master, making the issue, making the PR, and following through on review comments so far. When it comes to learning m

Week 2: Working on LinkStatus.go

Release 0.1 Project 

Hello again, this week I started and finished my release 0.1 project for my class. The project was to create a URL checker command line application with the choice of any language I wanted to use. So I decided to use GO since it is similar to C and C++ which I've worked with before so learning the basics of this language wouldn't be as rough.

Here is the GitHub Repo.

Development Process

To start I ran a simple "Hello World!" like starting to learn any other language. From there I researched and learned about the net/http package which allowed me to enter a URL and receive the status code back. A few if's and else statements later and I could now test for status codes ranging from 200, 400, and unknown or bad URLs.

After I was able to receive status codes I moved on to opening and reading text from a file. I placed a URL inside and extracted that into a string to then GET request a status code. 

The first real problem I encountered was finding URL's within a file filled with different text such as a .html file for example. To solve this I used the regex package to find URLs. I started by appending to a string each URL I found on a new line so I could access them easily. From there I set up a loop to read each line, make a new string, and then call my GET request function, passing along the new smaller single URL string along the way. The request would happen and then the next line of the string would be read and then sent over to the GET request function over, and over until I ran out of URL's to check.

The GET request function worked by receiving a URL in string form, ran a GET request on it, and stored the status code away. This status code was then checked for errors and ran through a few if's and else's to select the correct output to display.

Once this was done I moved onto making the command line interface. I ended up using a modified version of the flag package called pflag. Using pflag allowed me to create a custom version command so users could use "-v" or "--version" to get the version information. After this the rest of the command line setup was finish and now users could input files.

Another issue that I ran into was the program pausing for a long time on certain URL checks. To fix this I used the net/http package I was already using to introduce a timeout limit of seven seconds.

As of now the project is nearly complete with just some bug fixes and cleaning up of the code left. All major and optional features have now been implemented.

Program Features

  • Colour output for status codes
  • Timeout of max 7 seconds to the program doesn't stall
  • Two different ways to check the version (-v or --version)
  • Basic information on how to use
  • Ability to read supplied files

How to use the program

Once you have the files on your system and have GO installed you can simply just run "go run LinkStatus.go" to get helpful information about the program.

To get the version of the program you use "go run LinkStatus.go -v or --version"

Now the main function of the program, running "go run LinkStatus.go filename" will start reading and checking URLs from the given file.

Its funny as I literally write this blog I just noticed the URL output it counting by 2's. Another bug to fix.


Thanks for reading my second blog post! Another one is on the way for lab 1.

-Matt




Comments

Popular Posts