Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
Cloud - Assignment 2
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
Hans Kristian Hoel
Cloud - Assignment 2
Commits
6939b9a2
Commit
6939b9a2
authored
5 years ago
by
Hans Kristian Hoel
Browse files
Options
Downloads
Patches
Plain Diff
tring to read languages, not working for the moment
parent
c97305a2
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
assignment2/language.go
+30
-2
30 additions, 2 deletions
assignment2/language.go
assignment2/structs.go
+2
-1
2 additions, 1 deletion
assignment2/structs.go
with
32 additions
and
3 deletions
assignment2/language.go
+
30
−
2
View file @
6939b9a2
...
@@ -2,15 +2,31 @@ package assignment2
...
@@ -2,15 +2,31 @@ package assignment2
import
(
import
(
"encoding/json"
"encoding/json"
"fmt"
"log"
"log"
"net/http"
"net/http"
"strconv"
"strconv"
)
)
// func Counter(S []string) map[string]int {
// //List := strings.Fields(S)
// count := make(map[string]int)
// for _, Lang := range S {
// _, ok := count[Lang]
// if ok {
// count[Lang] += 1
// } else {
// count[Lang] = 1
// }
// }
// return count
// }
func
HandlerLanguages
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
HandlerLanguages
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
var
I
[]
IDLang
var
I
[]
IDLang
var
L
Language
var
L
Language
var
Code
[]
CodeType
URL1
:=
"https://git.gvk.idi.ntnu.no/api/v4/projects"
// main url
URL1
:=
"https://git.gvk.idi.ntnu.no/api/v4/projects"
// main url
URL2
:=
"https://git.gvk.idi.ntnu.no/api/v4/projects?private_token="
// url for token
URL2
:=
"https://git.gvk.idi.ntnu.no/api/v4/projects?private_token="
// url for token
...
@@ -48,6 +64,8 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
...
@@ -48,6 +64,8 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
I
=
append
(
I
,
TempID
...
)
// adds test to I
I
=
append
(
I
,
TempID
...
)
// adds test to I
fmt
.
Println
(
"len: "
,
len
(
I
))
}
}
for
i
:=
range
I
{
// loops true length of I
for
i
:=
range
I
{
// loops true length of I
...
@@ -56,16 +74,26 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
...
@@ -56,16 +74,26 @@ func HandlerLanguages(w http.ResponseWriter, r *http.Request) {
URL
=
URL
+
"?private_token="
+
auth
// adds token to link
URL
=
URL
+
"?private_token="
+
auth
// adds token to link
}
}
fmt
.
Println
(
URL
)
//****************************************************************
var
CodeTemp
[]
CodeType
resp
=
DoRequest
(
Client
,
w
,
URL
)
// request link
resp
=
DoRequest
(
Client
,
w
,
URL
)
// request link
err
=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
L
.
Languages
)
// decode to language
err
=
json
.
NewDecoder
(
resp
.
Body
)
.
Decode
(
&
CodeTemp
)
// decode to language
if
err
!=
nil
{
// check for error
if
err
!=
nil
{
// check for error
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
http
.
Error
(
w
,
err
.
Error
(),
http
.
StatusBadRequest
)
return
return
}
}
Code
=
append
(
Code
,
CodeTemp
...
)
}
}
// for CodeLang, NumCount := range Counter(Code) {
// fmt.Println(CodeLang, "=", NumCount)
// }
limit
:=
QueryGet
(
"limit"
,
"5"
,
r
)
// gets limit for localhost link
limit
:=
QueryGet
(
"limit"
,
"5"
,
r
)
// gets limit for localhost link
TempInt
,
err
:=
strconv
.
Atoi
(
limit
)
// turns sting to int
TempInt
,
err
:=
strconv
.
Atoi
(
limit
)
// turns sting to int
...
...
This diff is collapsed.
Click to expand it.
assignment2/structs.go
+
2
−
1
View file @
6939b9a2
...
@@ -28,7 +28,8 @@ type IDLang struct {
...
@@ -28,7 +28,8 @@ type IDLang struct {
}
}
type
CodeType
struct
{
type
CodeType
struct
{
Go
string
`json:"go"`
Codes
string
Num
int
}
}
type
Language
struct
{
type
Language
struct
{
...
...
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