WEEK 4: ENTRY 1

 At my internship today, I was tasked to restructure my code and deploy it to Gitlab. As part of my project, I will be querying Big Query, Google Cloud Platform, to generate a weekly report of certain logs. To make sure that I query from the Big Query, I must first of all establish connectivity to the Big Query API, which is the first step. Thus, the goal today was making sure that I was able to use the GET request that I learned last week and test it on a web server before creating the connectivity to the Big Query API. So too, I had to refactor my code so that I can only have one main to call and run all the different files and functions.  


Initially, I was running my code locally and printing to the Intellij terminal. I was also running each Go file independently. This was of course for testing but it was not great practice. I thought that by doing this, it would be easier to eventually call all these functions on my main.go file at last. But, it was quite a hassle today when I had to call these functions. I had two files: request.go and main.go. Just like how python files end with .py, Go programming files also end in .go. However, unlike python, where you would have to  import every function to another python file by using the keyword import,  go does a pretty great job with that differently. As a pythonista moving to Go, I carried the same ideology until I had to be reminded by my manager that Go does this in a more efficient manner. I spent almost two hours calling each function in the main.go file hoping that it would work, but it never did. In Go programming, one needs a directory that houses all the other program files, while the main.go file resides outside that directory. This way, the main.go would contain only one function, let’s say Execute(), which has all the calls of the functions in the app directory. Thus, all other files in the app directory will only contain code but the calling and executing happens in the main.go. I must confess that it was a very new concept and I had to struggle  with the function calls before my manager spotted it. 


Another insight I got today was how vital it is to continuously test and integrate to my Gitlab. I was busy coding my GET request function without continuously pushing and committing at successful intervals. I was so overwhelmed when I had to revert one of my commits  to a previous commit because a bug caused my most recent commit not to run correctly. Therefore, it is a lesson I learned and I intend to frequently push and commit code because that way when I have an unresolved bug fix, I can easily track which commit might have caused it, where the code was executing perfectly. . Basically today I learned how important it is to restructure my Go code and calling functions in Go in a more efficient manner. Thus, in the next days and weeks, I would be looking forward to applying this knowledge, while also paying attention to all the details I am given with regards to adhering to good coding practices.


Comments

Popular posts from this blog

WEEK 4: ENTRY 3

WEEK 6: ENTRY 3

WEEK 7: ENTRY 1