-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into lsp-client
- Loading branch information
Showing
22 changed files
with
429 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
import( | ||
"fmt" | ||
"math" | ||
) | ||
type a func() | ||
|
||
type Vertex struct { | ||
X, Y float64 | ||
} | ||
|
||
func (v Vertex) Abs() float64 { | ||
return math.Sqrt(v.X*v.X + v.Y*v.Y) | ||
} | ||
func (v *Vertex) Absp() float64{ | ||
return math.Sqrt(v.X*v.X + v.Y*v.Y) | ||
} | ||
|
||
func funcA () { | ||
fmt.Println("func A is called!") | ||
} | ||
|
||
func main() { | ||
a := funcA | ||
a() | ||
v := Vertex{3, 4} | ||
fmt.Println(v.Abs()) | ||
p := &Vertex{4,5} | ||
fmt.Println(p.Absp()) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
digraph go_test_repo { | ||
A -> B -> C; | ||
A -> B -> C -> D; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package sm | ||
|
||
func Add(a int, b int) int { | ||
return a + b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sm | ||
|
||
import "testing" | ||
|
||
func TestAdd1(t *testing.T) { | ||
r := Add(1, 2) | ||
|
||
if r != 3 { | ||
t.Errorf("Add(1, 2) failed. Got %d, expected 3.", r) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package sm | ||
|
||
import "math" | ||
|
||
func Sqrt(i int) int { | ||
v := math.Sqrt(float64(i)) | ||
return int(v) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/go_test_repo_1/A/calcproj/src/simplemath/sqrt_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sm | ||
|
||
import "testing" | ||
|
||
func TestSqrt1(t *testing.T) { | ||
v := Sqrt(16) | ||
|
||
if v != 4 { | ||
t.Errorf("Sqrt(16) failed. Got %v, expected 4.", v) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ("os" | ||
"fmt" | ||
"strconv" | ||
"gitlab.com/meri.co/test/calcproj/src/simplemath") | ||
|
||
var Usage = func() { | ||
fmt.Println("USAGE: calc command [arguments] ...") | ||
fmt.Println("\nThe commands are:\n\tadd\tAddition of two values.\n\tsqrt\tSquare root of a non-negative value.") | ||
} | ||
|
||
func main() { | ||
args := os.Args | ||
if args == nil || len(args) < 2 { | ||
Usage() | ||
return | ||
} | ||
|
||
switch args[1] { | ||
case "add": | ||
if len(args) != 4 { | ||
fmt.Println("USAGE: calc add <integer1> <integer2>") | ||
return | ||
} | ||
|
||
v1, err1 := strconv.Atoi(args[2]) | ||
v2, err2 := strconv.Atoi(args[3]) | ||
if err1 != nil || err2 != nil { | ||
fmt.Println("USAGE: calc add <integer1> <integer2>") | ||
return | ||
} | ||
|
||
ret := sm.Add(v1, v2) | ||
fmt.Println("Result: ", ret) | ||
case "sqrt": | ||
if len(args) != 3 { | ||
fmt.Println("USAGE: calc sqrt <integer>") | ||
return | ||
} | ||
|
||
v, err := strconv.Atoi(args[2]) | ||
if err != nil { | ||
fmt.Println("USAGE: calc sqrt <integer>") | ||
return | ||
} | ||
|
||
ret := sm.Sqrt(v) | ||
fmt.Println("Result: ", ret) | ||
default: | ||
Usage() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package sm | ||
|
||
func Add(a int, b int) int { | ||
return a + b | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sm | ||
|
||
import "testing" | ||
|
||
func TestAdd1(t *testing.T) { | ||
r := Add(1, 2) | ||
|
||
if r != 3 { | ||
t.Errorf("Add(1, 2) failed. Got %d, expected 3.", r) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package sm | ||
|
||
import "math" | ||
|
||
func Sqrt(i int) int { | ||
v := math.Sqrt(float64(i)) | ||
return int(v) | ||
} |
11 changes: 11 additions & 0 deletions
11
test/go_test_repo_1/B/calcproj/src/simplemath/sqrt_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package sm | ||
|
||
import "testing" | ||
|
||
func TestSqrt1(t *testing.T) { | ||
v := Sqrt(16) | ||
|
||
if v != 4 { | ||
t.Errorf("Sqrt(16) failed. Got %v, expected 4.", v) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
digraph go_test_repo { | ||
A -> B ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
import( | ||
"fmt" | ||
) | ||
//This test code is used for test interface function call | ||
type animal interface { | ||
printInfo() | ||
} | ||
|
||
type cat int | ||
type dog int | ||
|
||
func (c cat) printInfo(){ | ||
fmt.Println("a cat") | ||
} | ||
|
||
func (d dog) printInfo(){ | ||
fmt.Println("a dog") | ||
} | ||
|
||
func main() { | ||
var a animal | ||
var c cat | ||
a=c | ||
a.printInfo() | ||
//other type | ||
var d dog | ||
a=d | ||
a.printInfo() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package main | ||
import( | ||
"fmt" | ||
) | ||
//This test code is used for test interface function call | ||
type animal interface { | ||
printInfo() | ||
} | ||
|
||
type cat int | ||
type dog int | ||
func (c cat) printInfo(){ | ||
fmt.Println("a cat") | ||
} | ||
|
||
func (c dog) printInfo(){ | ||
fmt.Println("a dog") | ||
} | ||
func invoke(a animal){ | ||
a.printInfo() | ||
} | ||
func main() { | ||
var c cat | ||
var d dog | ||
//as value convert | ||
invoke(c) | ||
invoke(d) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
digraph go_test_repo { | ||
A -> B ; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.