Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
tsingbx committed Oct 13, 2023
2 parents 1ae63dd + e10c838 commit 3103721
Show file tree
Hide file tree
Showing 54 changed files with 486 additions and 462 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/go.yml → .github/workflows/gop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a golang project
# This workflow will build a goplus project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go
name: Go+

on:
push:
Expand All @@ -16,11 +16,12 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
- name: Set up Go/Go+
uses: goplus/setup-goplus@v1
with:
go-version: '1.18'
go-version: "1.18"
gop-version: "1.1.8"

- name: Build
run: |
go build -v ./...
gop go -t -s ./...
60 changes: 30 additions & 30 deletions 103-Constants/constants.gop
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// Go+ supports _constants_ of character, string, boolean,
// and numeric values.
import (
"math"
)
// `const` declares a constant value.
const s string = "constant"
println s
// A `const` statement can appear anywhere a `var`
// statement can.
const n = 500000000
// Constant expressions perform arithmetic with
// arbitrary precision.
const d = 3e20 / n
println d
// A numeric constant has no type until it's given
// one, such as by an explicit conversion.
println int64(d)
// A number can be given a type by using it in a
// context that requires one, such as a variable
// assignment or function call. For example, here
// `math.sin` expects a `float64`.
println math.sin(n)
// Go+ supports _constants_ of character, string, boolean,
// and numeric values.

import (
"math"
)

// `const` declares a constant value.
const s string = "constant"

println s

// A `const` statement can appear anywhere a `var`
// statement can.
const n = 500000000

// Constant expressions perform arithmetic with
// arbitrary precision.
const d = 3e20 / n
println d

// A numeric constant has no type until it's given
// one, such as by an explicit conversion.
println int64(d)

// A number can be given a type by using it in a
// context that requires one, such as a variable
// assignment or function call. For example, here
// `math.sin` expects a `float64`.
println math.sin(n)
55 changes: 28 additions & 27 deletions 104-Variables/vars.gop
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
// In Go+, _variables_ are explicitly declared and used by
// the compiler to e.g. check type-correctness of function
// calls.

// `var` declares 1 or more variables.
var a = "initial"
println a

// You can declare multiple variables at once.
var b, c int = 1, 2
println b, c

// Go+ will infer the type of initialized variables.
var d = true
println d

// Variables declared without a corresponding
// initialization are _zero-valued_. For example, the
// zero value for an `int` is `0`.
var e int
println e

// The `:=` syntax is shorthand for declaring and
// initializing a variable, e.g. for
// `var f string = "apple"` in this case.
f := "apple"
println f
// In Go+, _variables_ are explicitly declared and used by
// the compiler to e.g. check type-correctness of function
// calls.

// `var` declares 1 or more variables.
var a = "initial"

println a

// You can declare multiple variables at once.
var b, c int = 1, 2
println b, c

// Go+ will infer the type of initialized variables.
var d = true
println d

// Variables declared without a corresponding
// initialization are _zero-valued_. For example, the
// zero value for an `int` is `0`.
var e int
println e

// The `:=` syntax is shorthand for declaring and
// initializing a variable, e.g. for
// `var f string = "apple"` in this case.
f := "apple"
println f
1 change: 1 addition & 0 deletions 105-Assignments/assign.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions 106-Types/types.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions 107-Integers/integers.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions 108-Floating-Point-Numbers/numbers.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions 109-Complex-Numbers/complex.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions 110-Booleans/boolean.gop
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

102 changes: 51 additions & 51 deletions 111-Strings/strings.gop
Original file line number Diff line number Diff line change
@@ -1,51 +1,51 @@
// A string is a sequence of bytes that cannot be changed. Strings can contain any data
// and are generally used to save text.
//
// We generally use double quotes "" to define a string, but note that there are specific
// characters that have a specific meaning, which we call escaped characters, and these
// escaped characters contain:
//
// <pre style="font-size:small">
// \n:line break
// \r:Enter
// \t:Tab
// \u or \U:Unicode
// \:Backslash
// </pre>
println("hello" + "\t" + "world") // hello world
// If we want to know the length of the strings taken up by bytes, we can use Go+'s built-in
// functions to calculate it:
println(len("helloword")) // 9
// If we were to define a string, the grammar would be as follows:
str := "helloword"
println(str) // helloword
println(len(str)) // 9
// We can stitch two strings together by +, appending the later string to the later of the
// earlier string.
str1 := "hello" + "word"
println(str1) // helloword
str2 := "my name is \t"
str3 := "zs"
println(str2 + str3) // my name is zs
// If we want to define a multi-line string, Go+ supports that too. Using the traditional
// "" is not possible across lines, we can use backquotes if we want to define a multi-line
// string: `
const str4 = `First line
Second line
Third line
`
println(str4)
// The code between the backquotes is not recognized by the editor, but only as part of
// the string.
// A string is a sequence of bytes that cannot be changed. Strings can contain any data
// and are generally used to save text.
//
// We generally use double quotes "" to define a string, but note that there are specific
// characters that have a specific meaning, which we call escaped characters, and these
// escaped characters contain:
//
// <pre style="font-size:small">
// \n:line break
// \r:Enter
// \t:Tab
// \u or \U:Unicode
// \:Backslash
// </pre>

println("hello" + "\t" + "world") // hello world

// If we want to know the length of the strings taken up by bytes, we can use Go+'s built-in
// functions to calculate it:

println(len("helloword")) // 9

// If we were to define a string, the grammar would be as follows:

str := "helloword"
println(str) // helloword
println(len(str)) // 9

// We can stitch two strings together by +, appending the later string to the later of the
// earlier string.

str1 := "hello" + "word"
println(str1) // helloword

str2 := "my name is \t"
str3 := "zs"

println(str2 + str3) // my name is zs

// If we want to define a multi-line string, Go+ supports that too. Using the traditional
// "" is not possible across lines, we can use backquotes if we want to define a multi-line
// string: `

const str4 = `First line
Second line
Third line
`
println(str4)

// The code between the backquotes is not recognized by the editor, but only as part of
// the string.
56 changes: 28 additions & 28 deletions 113-If&#47;Else/if-else.gop
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// Branching with `if` and `else` in Go+ is
// straight-forward.
// Here's a basic example.
if 7%2 == 0 {
println "7 is even"
} else {
println "7 is odd"
}
// You can have an `if` statement without an else.
if 8%4 == 0 {
println "8 is divisible by 4"
}
// A statement can precede conditionals; any variables
// declared in this statement are available in all
// branches.
if num := 9; num < 0 {
println num, "is negative"
} else if num < 10 {
println num, "has 1 digit"
} else {
println num, "has multiple digits"
}
// Note that you don't need parentheses around conditions
// in Go+, but that the braces are required.
// Branching with `if` and `else` in Go+ is
// straight-forward.

// Here's a basic example.
if 7%2 == 0 {
println "7 is even"
} else {
println "7 is odd"
}

// You can have an `if` statement without an else.
if 8%4 == 0 {
println "8 is divisible by 4"
}

// A statement can precede conditionals; any variables
// declared in this statement are available in all
// branches.
if num := 9; num < 0 {
println num, "is negative"
} else if num < 10 {
println num, "has 1 digit"
} else {
println num, "has multiple digits"
}

// Note that you don't need parentheses around conditions
// in Go+, but that the braces are required.
Loading

0 comments on commit 3103721

Please sign in to comment.