Featured
- Get link
- X
- Other Apps
Week 7: Lab 6: Starting with Telescope and using Gist
The Lab
This weeks lab was all about starting to learn how to work with Telescope and to setup its development environment. I also learned how to make a gist and use the diff command.
Setting up Telescopes environment was a real struggle. There is just so many moving parts going into the project that it was quite a task to get it running, though I'm still not quite sure if I got it running correctly. I ended setting up Redis Server and Elastic Search locally on my machine. Elastic Search seems to be working correctly since I was able to access the blog feeds, but I'm still not too sure about Redis.
Changing my LinkStatus program
I actually needed to put in a lot of changes to get the program to work with telescope. I added a new command that would start the whole telescope process called "-t". Using ./LinkStatus http://localhost:3000/posts -t would access the 10 most recent blog URLs and convert them into a JSON file. I then setup a struct to hold this data so I could then parse and format it into a proper URL into a another new file. With this I could use my program normally without many changes besides a new regex pattern to look for localhost URLs.
Here's the new Telescope output:
Since I had access to the JSON format for the blog data (id, URL) I choose to construct the URLs since each of them followed a similar pattern. I simply just appended "/posts/url" onto a premade string and appending that data to a file. The function completed a few important tasks:
- Create a JSON file
- Perform a Get request on localhost:3000
- Read and pull all the JSON data into the file
- Create an object of type Telescope to hold the id and URL values
- Populate that object with the data using Unmarshal
- Create a new text file
- Write to the new text file a constructed URL using the URL value
Here's the new Struct and the new function to make this all work:
Since I'm new to working with GO, I had to research quite a bit on how to work with JSON data for this lab. I ended up using the encoding/json package to work with the data and it went pretty well.
With a newly created file in hand the program works as normal, but a some additional of a new regex pattern in file.go was introduced to handle localhost URLs.
Using Gist and Diff
Once my work was finishing I had to create a gist to easily share my work. I added my two files I worked on then started to think how to use the diff command. At first I thought maybe download for gist with old and new files to then run the command, but after searching up the diff command docs I found out how to specify branches. From here I used git diff telescope master -- main.go.
I ran this command on both my files and added it to my gist.
What's Next?
Over the course of this weekend and the next week Im going to be working with Telescope to finish my release 0.3 assignment. I already went out and got assigned for an issue to solve, so now I can focus on learning how to work with and solve this issue.
The issue I decided to work on was to add an additional feature to the search bar. I would need to make the program support autocomplete on the authors name as you would be typing and have them come up underneath the search bar. Add autocomplete to search for Authors #1260
- Get link
- X
- Other Apps
Comments
Post a Comment