pokt-network/pocket

[Core] Fix named imports across the entire codebase

Opened this issue · 5 comments

Objective

Follow best Golang practices w.r.t named imports

Origin Document

Screenshot 2023-07-05 at 2 50 44 PM

Goals

  • Follow best practices in Go
  • Stay consistent w.r.t imports throughout the codebase

Deliverable

  • Identify and update all named imports in Go that are CamelCase and change them to snake_case

Non-goals / Non-deliverables

  • Any business logic changes

General issue deliverables

  • Update the appropriate CHANGELOG(s)
  • Update any relevant local/global README(s)
  • Update relevant source code tree explanations
  • Add or update any relevant or supporting mermaid diagrams

Testing Methodology

  • Task specific tests or benchmarks: make ...
  • New tests or benchmarks: make ...
  • All tests: make test_all
  • LocalNet: verify a LocalNet is still functioning correctly by following the instructions at docs/development/README.md
  • k8s LocalNet: verify a k8s LocalNet is still functioning correctly by following the instructions here

Creator: @Olshansk

@kutoft We discussed you trying out a core starter task issue to get "hands on" with the codebase. Wdyt of this one?

@kutoft Do you want to try and tackle this in the upcoming iteration?

tl;dr Goal is to make all named imports snake_case

(2) is what we DON'T WANT and (1) is what we DO WANT

  1. If we do a regex search all camelCase imports (e.g. ^\s*([a-z]+(?:[A-Z][a-z]*)*)\s), we find the following:

Screenshot 2023-07-31 at 2 19 22 PM

  1. If we do a regex search all snake_case imports (e.g. ^\s*([a-z]+_[a-z_]+)\s+"github\.com(.*?)"), we find the following:

Screenshot 2023-07-31 at 2 20 17 PM

kutoft commented

@Olshansk Your message seems a little contradictory. So I just want to confirm which casing structure you want here, camelCase or snake_case.

Additionally, I was reading up on GO language patterns, and it appears the common practice is to name packages as all lowercase. Would you rather stick with this convention?

https://go.dev/blog/package-names

Response to the question is below but please hold off on implementation until further notice while our team reevaluated priorities.


Additionally, I was reading up on GO language patterns, and it appears the common practice is to name packages as all lowercase. Would you rather stick with this convention?

Yes. Attaching the GPT screenshot from our offline conversation for reference.

ChatGPT-Go_Naming_Conventions

Tl;dr

  1. Replace snake_case with lowercase
  2. Replace PascalCase with lowercase
  3. Replace camelCase with lowercast