Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cloud-assignment-02
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nils Petter Skålerud
cloud-assignment-02
Commits
932307d5
Commit
932307d5
authored
2 years ago
by
Marius Nersveen
Browse files
Options
Downloads
Patches
Plain Diff
Storing the filepath of the CSV file in a variable
parent
89d30367
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
handlers/currentPercentageHandler.go
+2
-1
2 additions, 1 deletion
handlers/currentPercentageHandler.go
utils/constants.go
+1
-0
1 addition, 0 deletions
utils/constants.go
utils/variables.go
+16
-0
16 additions, 0 deletions
utils/variables.go
with
19 additions
and
1 deletion
handlers/currentPercentageHandler.go
+
2
−
1
View file @
932307d5
package
handlers
import
(
"Assignment02/utils"
"encoding/csv"
"fmt"
"net/http"
...
...
@@ -16,7 +17,7 @@ func HandleGetRequestForCurrentPercentage(w http.ResponseWriter, r *http.Request
//countryName := URLParts[??]
// Open the CSV file
fd
,
err
:=
os
.
Open
(
"renewable-share-energy.csv"
)
fd
,
err
:=
os
.
Open
(
utils
.
CsvFilePath
)
if
err
!=
nil
{
fmt
.
Println
(
"Error opening CSV file."
)
fmt
.
Println
(
err
)
...
...
This diff is collapsed.
Click to expand it.
utils/constants.go
+
1
−
0
View file @
932307d5
...
...
@@ -6,3 +6,4 @@ const CURRENT_PATH = "/energy/v1/renewables/current/"
const
HISTORY_PATH
=
"/energy/v1/renewables/history/"
const
NOTIFICATIONS_PATH
=
"/energy/v1/notifications/"
const
STATUS_PATH
=
"/energy/v1/status/"
const
CSV_FILE_PATH
=
"utils/renewable-share-energy.csv"
This diff is collapsed.
Click to expand it.
utils/variables.go
0 → 100644
+
16
−
0
View file @
932307d5
package
utils
import
(
"fmt"
"path/filepath"
)
func
getCSVFilepath
()
string
{
absPath
,
err
:=
filepath
.
Abs
(
CSV_FILE_PATH
)
if
err
!=
nil
{
fmt
.
Println
(
"Error getting absolute path:"
,
err
)
}
return
absPath
}
var
CsvFilePath
=
getCSVFilepath
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment