Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added one Useful Link #7

Open
wants to merge 199 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
199 commits
Select commit Hold shift + click to select a range
dd52599
[design-patterns] update quick_sort.go
betty200744 Aug 13, 2020
66e5b72
[design-patterns] add proxy.go and proxy_test.go
betty200744 Aug 17, 2020
c914f1a
[algorithms] update singlylinkedlist_test.go
betty200744 Aug 24, 2020
c886f1c
[doc] update readme.md
betty200744 Aug 24, 2020
3709866
[doc] update readme.md
betty200744 Aug 24, 2020
e4cfdd0
[doc] update readme.md, fixed typo
betty200744 Aug 24, 2020
b9fe87c
[algorithms] add fibonacci.go
betty200744 Aug 24, 2020
4d31b39
[algorithms] update readme.md
betty200744 Aug 24, 2020
fd65565
utilize iota as val on top enum dict
coip Aug 24, 2020
9efeb6a
fix iota syntax, potentially better ref depth/coherency
coip Aug 24, 2020
0795252
fix broken string lookup in map
coip Aug 24, 2020
dd133f5
Merge pull request #2 from coip/patch-1
betty200744 Aug 24, 2020
8f5158d
[algorithms] add gcd
betty200744 Aug 25, 2020
5814620
[algorithms][data-structures] stack add max method
betty200744 Aug 25, 2020
d688202
[algorithms][data-structures] update fibonacci.go
betty200744 Aug 25, 2020
c2d23a6
[LeetCode] add 230_KthSmallest.go
betty200744 Aug 28, 2020
084985b
[algorithms] update BreadthFirst
betty200744 Aug 28, 2020
c4362a4
[leetcode] add 287_findDuplicate.go and 287_findDuplicate_test.go
betty200744 Aug 28, 2020
c5e2641
[leetcode][lcof] add 3_findRepeatNumber.go
betty200744 Aug 28, 2020
1de69dd
[leetcode][lcof] add 27_mirrorTree.go
betty200744 Aug 28, 2020
632a026
[leetcode][lcof] add 27_mirrorTree.go
betty200744 Aug 28, 2020
0ab35a1
[leetcode][lcof] add KthBiggest
betty200744 Aug 29, 2020
b2ca78f
[leetcode] add 199_Binary_Tree_Right_Side_View.go RightSideView , and…
betty200744 Aug 29, 2020
453eb42
[leetcode] add 112_Path_Sum.go
betty200744 Aug 29, 2020
b0db7da
[Language_Specification] fixed https://github.com/betty200744/ultimat…
betty200744 Aug 29, 2020
388c48d
[awesome-go][go-redis] watch transaction
betty200744 Aug 30, 2020
f12ed58
[awesome-go][go-redis] add freecache example.go
betty200744 Aug 31, 2020
8dba69c
[awesome-go][freecache] add wrapper freecache
betty200744 Aug 31, 2020
574ceea
[leetcode] add index_range.go and index_range_test.go
betty200744 Aug 31, 2020
462b9b1
[leetcode] add addTwoNumbers.go and addTwoNumbers_test.go
betty200744 Aug 31, 2020
77b2042
[leetcode] add 14_longestCommonPrefix.go
betty200744 Sep 1, 2020
52fd282
[leetcode] add 344_reverseString.go
betty200744 Sep 1, 2020
0e00695
[leetcode] add 76_minWindow.go
betty200744 Sep 1, 2020
8fbddfb
[leetcode] add 7_reverseInt.go
betty200744 Sep 1, 2020
d1f2e1c
[leetcode] update reverseString.go
betty200744 Sep 1, 2020
2002a31
[leetcode] add 226_invertTree.go
betty200744 Sep 1, 2020
6326cb7
[leetcode] add 102_107_levelOrder.go
betty200744 Sep 2, 2020
c876a54
[leetcode] add TestGivenLevelOrderFromRight
betty200744 Sep 2, 2020
d0a64c1
[leetcode] add 144_145_traversal.go
betty200744 Sep 2, 2020
e91ce1f
[leetcode] add 144_145_traversal.go PreOrderIterative
betty200744 Sep 2, 2020
4217b50
[leetcode] add 543_diameterOfBinaryTree.go
betty200744 Sep 2, 2020
aa2aa85
[leetcode] add 509_fibonacciNumber.go
betty200744 Sep 3, 2020
f884420
[leetcode] update 509_fibonacciNumber.go add FibonacciNumber use Dyna…
betty200744 Sep 3, 2020
d176782
[Language_Specification] update channel.go
betty200744 Sep 3, 2020
b3df412
[leetcode] add 160_getIntersectionNode.go
betty200744 Sep 4, 2020
e99a82e
[leetcode] add 204_countPrimes.go
betty200744 Sep 4, 2020
79c6806
[leetcode] dynamic programing add 198_house_Robber.go
betty200744 Sep 5, 2020
91d3403
[Language_Specification] update channel.go
betty200744 Sep 5, 2020
8e20a6b
[leetcode] add 198_house_Robber.go
betty200744 Sep 5, 2020
ffb2c38
[leetcode] update
betty200744 Sep 6, 2020
ee54f0b
[leetcode] add knapsack.go and knapsack_test.go
betty200744 Sep 6, 2020
0c7d710
[leetcode] add 322_coinChange.go
betty200744 Sep 7, 2020
42d23db
[leetcode] update 198_house_Robber.go
betty200744 Sep 7, 2020
f8b3bf1
[leetcode] update knapsack.go
betty200744 Sep 7, 2020
d7a35dd
[leetcode] update knapsack.go
betty200744 Sep 7, 2020
32c7161
[leetcode] add 21_exchange.go
betty200744 Sep 7, 2020
e703d74
[leetcode] add 378_kthSmallest.go
betty200744 Sep 7, 2020
cd79c5a
[leetcode] update 204_countPrimes.go
betty200744 Sep 7, 2020
44dd3ba
[leetcode] add 670_maximumSwap.go
betty200744 Sep 10, 2020
40ffab4
[Language_Specification] add struct_to_map.go
Sep 30, 2020
8fb2989
[awesome-go] add json, toml, yaml config
Oct 4, 2020
c1654bd
[awesome-go] add http Read body
Oct 13, 2020
c0f6afa
[awesome-go] add filepath_abs.go
Oct 15, 2020
7f9c66b
[awesome-go] add filepath_abs.go
Oct 15, 2020
e8df856
[awesome-go] update filepath.go
Nov 1, 2020
0c9160a
[awesome-go] statements.go
Nov 1, 2020
c8d66fc
[awesome-go] reflection
Nov 1, 2020
15ba0b8
[awesome-go] utils.go
Nov 1, 2020
11bb311
[utils] add encrypt.go
Nov 7, 2020
74d667c
[encoding] add base64.go and base64_test.go
Nov 7, 2020
f516d06
[encoding] update encoding
Nov 8, 2020
1d640d0
[crypto] update crypto
Nov 8, 2020
abe2eef
[utils] add encrypt.go
Nov 8, 2020
ed49131
[utils] add ctx_test.go
Nov 8, 2020
9fe661a
[utils] add network.go
Nov 8, 2020
d536bd3
[utils] add str
Nov 8, 2020
2e31689
[utils] array.go
Nov 8, 2020
8e1f933
[utils] remove
Nov 8, 2020
3362bb1
[utils] up str.go
Nov 8, 2020
06ca37f
[utils] add encrypt.go
Nov 9, 2020
acabb3c
[awesome-go] add cron
Nov 21, 2020
a8339be
[crypto] add AESEncrypt and AESDecrypt
Nov 22, 2020
85ca6dd
[time] duration.go
Nov 29, 2020
26d3138
[time] tickers.go
Nov 29, 2020
3879a3a
[time] add format.go
Nov 29, 2020
2d14676
[awesome] add now
Dec 6, 2020
9614b37
[build-in] time
Dec 6, 2020
ffb547e
[up] go.mod
Dec 6, 2020
87907f3
[io] ioutil.go
Dec 6, 2020
c51cdb4
[mapstructure] add JsonTagDecode
Dec 12, 2020
d1b219a
[build-in] time
Dec 12, 2020
76530dd
[build-in] add AES , CBC, ECB Encrypt and Decrypt
Dec 12, 2020
eb4f635
[jwt-go] add jwt wrapper
Dec 13, 2020
a5735e4
[build-in] cipher.go
Dec 13, 2020
c46754d
[build-in] http client (Get, GetImage, Post, PostJson,DoPost, PostFile )
Dec 13, 2020
04528e1
[build-in] http
Dec 13, 2020
5f9f1e3
[build-in] url
Dec 13, 2020
74ad41d
[build-in] time
Dec 13, 2020
bf6ce5c
[build-in] time
Dec 13, 2020
c7b6272
[build-in] text and html template
Jan 9, 2021
176986f
[build-in] user_concurrency.go
Jan 18, 2021
a1e6570
[build-in] time
Jan 18, 2021
1d98210
[build-in] LICENSE.txt
Jan 19, 2021
5b0018c
[awesome] add https://github.com/flyaways/pool
Jan 19, 2021
4d16106
[rabbitmq] add simple producer.go, consumer.go
Jan 23, 2021
ccfe900
[rabbitmq] add simple producer.go, consumer.go
Jan 23, 2021
55c86a4
[rabbitmq] add queue , task.go, work.go
Jan 23, 2021
a73e2e8
[rabbitmq] add pub_sub , producer.go, consumer.go
Jan 23, 2021
7a57e78
[rabbitmq] add pub_sub , producer.go, consumer.go
Jan 23, 2021
14854d1
[rabbitmq] add pub_sub , producer.go, consumer.go
Jan 24, 2021
a177e00
[rpcx] add rpcx
Jan 25, 2021
4cff1b8
[go-fastping] add ping
Jan 25, 2021
80c9807
[sql] open
Jan 26, 2021
ecf0ad7
[sql] open
Jan 26, 2021
8bbaaac
[build-in-package] add atomic value.go
Jan 27, 2021
768cad4
[build-in-package] add atomic value.go
Jan 30, 2021
f7ba91a
[socket] add go-socket-server.go
Jan 31, 2021
a94a515
[sync]
Apr 5, 2021
afe8264
[build-in-package] add flag
Apr 7, 2021
f07d48b
[awesome] add rpcx demo
Apr 7, 2021
c1aa7fe
[awesome] add rpcx demo
Apr 7, 2021
42f6380
[awesome] add rpcx peer2peerDiscovery demo
Apr 26, 2021
058cff9
[awesome] bidirectional xclient
Apr 26, 2021
901b5c9
[build-in] add tcp server.go and tcp client.go
May 7, 2021
ec997b4
[awesome] add influxdb-client-go
May 16, 2021
d4d15cf
[awesome] rpcx plugin demo
May 30, 2021
4f04232
[awesome] up go.mod
May 30, 2021
2d65de1
[awesome] up go.mod
May 30, 2021
85d52f8
[build-in-package][net] add tcp client (Dial) and tcp server (Listen)
May 30, 2021
cd4d5c7
[build-in-package][net] up tcp
May 30, 2021
efb69ac
[build-in-package][net] up tcp
May 30, 2021
f49ce71
[awesome-go] bazel up
May 30, 2021
6f8c281
[build-in-package][net] add udp
May 30, 2021
15e7133
[build-in-package][net] add udp
May 30, 2021
48b7bab
[awesome-go][influxdb] v1
Jun 1, 2021
67c16c8
[awesome-go][influxdb] add write_data.go and write_data_test.go
Jun 4, 2021
eb73e3f
[awesome-go][influxdb] add query_data.go query_data_test.go
Jun 5, 2021
9823d9c
[awesome-go][influxdb] add aggregateWindow
Jun 5, 2021
c23af1b
[build-in-package] add sync.Cond
Jun 13, 2021
1b8bcf3
[up]
Jun 13, 2021
8e86f77
[up] ticker add stop
Jun 13, 2021
2b60d5a
[utils] add RandInt64
Jun 13, 2021
e124d81
[kubernetes] add k8s
Aug 4, 2021
c468397
[up]
Aug 4, 2021
cba4052
[solid] add simple responsibility principle
Aug 14, 2021
813338d
[object_oriented]
Aug 15, 2021
34b9f0a
[object_oriented]
Aug 15, 2021
c910371
[build-in-package] up flag
Aug 28, 2021
78b41b2
[diagnostics] http pprof
Aug 28, 2021
9b7025b
[diagnostics] runtime pprof cpu
Aug 28, 2021
187df12
[diagnostics] runtime pprof mem
Aug 28, 2021
15f14df
[diagnostics] img and readme.md
Aug 28, 2021
6f0505f
[diagnostics] add trace.go
Aug 28, 2021
ca64739
[diagnostics] add trace.go
Aug 28, 2021
0e64224
[go_modules] up
Aug 28, 2021
39ae47d
Translate the interface section to english. Because in a interface, i…
ufo22940268 Aug 29, 2021
9c113f3
Merge pull request #6 from ufo22940268/master
betty200744 Aug 29, 2021
f088619
[ultimate-go] up readme.md
Aug 29, 2021
7dce436
[ultimate-go] up readme.md
Aug 30, 2021
8a09c7f
[ultimate-go] up readme.md
Aug 30, 2021
edeffe9
[ultimate-go]
Aug 31, 2021
3270373
[diagnostics] up
Sep 5, 2021
577cc37
[build-in-package] singleflight.go
Sep 11, 2021
bc559cd
[diagnotics] trace.go
Sep 11, 2021
825cdaf
[build-in-package] add ip2int and int2ip
Sep 11, 2021
fb3b49e
[build-in-package] add simplehttpserver.go
Sep 11, 2021
49b5f9b
[ultimate-go] add cli
Sep 11, 2021
2b96692
[ultimate-go] add cli
Sep 11, 2021
ab0b139
[ultimate-go] up cli , add cli Flag and Flag Destination
Sep 11, 2021
535b95b
[ultimate-go] up
Sep 12, 2021
f238c52
[packr] config tmpl
Sep 12, 2021
9564d27
[ultimate-go] packr init
Sep 12, 2021
0aaa3cb
[ultimate-go] protoc , gogoproto , gen message, gen grpc ,gen gateway…
Sep 12, 2021
905ed98
[ultimate-go] protoc , gogoproto , gen message, gen grpc ,gen gateway…
Sep 12, 2021
90c6789
[ultimate-go] up
Sep 21, 2021
fdf8e1d
[ultimate-go] update
Oct 1, 2021
246ed14
[build-in-package] net tcp conn
Oct 1, 2021
801712f
[build-in-package] net tcp conn
Oct 1, 2021
a56bbdd
[build-in-package] dns lookup
Oct 1, 2021
01ccbf0
[encoding] update
Oct 1, 2021
8a1912e
[build-in-package] websocket echo
Oct 2, 2021
138f953
update readme.md
Oct 2, 2021
b6daf46
add gorilla websocket service and client
Oct 3, 2021
045b0c5
gorilla-websocket, mv to chat
Oct 3, 2021
2d68567
[awesome-go] add consul register.go and register_test.go
Oct 5, 2021
8f932d8
grpc-go add consul register
Oct 5, 2021
6cad9e5
grpc-go add register and grpc consul resolver
Oct 5, 2021
2cf320c
format register_test.go
Oct 5, 2021
5a572d0
consul init consul-resolver.go
Oct 5, 2021
9466359
grpc-go update version
Oct 5, 2021
f70f2cc
update readme.md
Oct 5, 2021
08e67fd
update readme.md
Oct 5, 2021
bf9fd86
kubernetes with istio
Oct 7, 2021
d984b94
add configmaps
Dec 7, 2021
bf9089a
add configmaps
Dec 7, 2021
851d321
use istio ingress
Dec 8, 2021
2d2dd6f
[build-in-package] sync pool
Dec 8, 2021
643c07b
[build-in-package] timers retry by timer
Dec 9, 2021
a497534
Added one Useful Link
bikashdaga Jul 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
26 changes: 9 additions & 17 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
/awesome-go/bazel/cpp-tutorial/stage1/bazel-bin/
/awesome-go/bazel/cpp-tutorial/stage1/bazel-out/
/awesome-go/bazel/cpp-tutorial/stage1/bazel-stage1/
/awesome-go/bazel/cpp-tutorial/stage1/bazel-testlogs/
/awesome-go/bazel/cpp-tutorial/stage1/bazel-bin/
/awesome-go/bazel/cpp-tutorial/stage1/bazel-out/
/awesome-go/bazel/cpp-tutorial/stage1/bazel-stage1/
/awesome-go/bazel/cpp-tutorial/stage1/bazel-testlogs/
/awesome-go/bazel/go-tutorial/bazel-bin/
/awesome-go/bazel/go-tutorial/bazel-go-tutorial/
/awesome-go/bazel/go-tutorial/bazel-out/
/awesome-go/bazel/go-tutorial/bazel-testlogs/
/awesome-go/bazel/go-tutorial/bazel-bin/
/awesome-go/bazel/go-tutorial/bazel-go-tutorial/
/awesome-go/bazel/go-tutorial/bazel-out/
/awesome-go/bazel/go-tutorial/bazel-testlogs/
/.idea/inspectionProfiles/Project_Default.xml
/build-in-package/http/2IRnmVm
/build-in-package/http/5401ebbeaa94302f60bed3d06409139d.png
/awesome-go/rpcx/registry/consul/client/client.go
/awesome-go/rpcx/registry/consul/oneclient/client.go
/awesome-go/rpcx/registry/multiple/client/client.go
/build-in-package/http/keyboard.jpeg
/awesome-go/rpcx/registry/consul/server/server.go
/awesome-go/rpcx/registry/multiple/server/server.go
/.idea/codeStyles/codeStyleConfig.xml
24 changes: 24 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

Copyright (c) 2012-2019, Sean Treadway, SoundCloud Ltd.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"gobyexample/Language_Specification/errors"
"ultimate-go/Language_Specification/errors"
)

// panic, 立刻stops execution the current function, then unwinding the stack, then run deferred functions
Expand Down
24 changes: 0 additions & 24 deletions Language_Specification/build-in-type/flag.go

This file was deleted.

43 changes: 43 additions & 0 deletions Language_Specification/build-in-type/str/str.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package str

import (
"encoding/base64"
"fmt"
"strconv"
"strings"
)

func Base64Encode(s string) string {
return base64.StdEncoding.EncodeToString([]byte(s))
}
func Base64Decode(s string) string {
b, err := base64.StdEncoding.DecodeString(s)
if err != nil {
return ""
}
return string(b[:])
}
func IdsString2Slice(s string) []int64 {
if s == "" {
return []int64{}
}
arr := strings.Split(s, ",")
n := len(arr)
ids := make([]int64, 0, n)
for _, s2 := range arr {
i64, err := strconv.ParseInt(s2, 10, 64)
if err == nil {
ids = append(ids, i64)
}
}
return ids
}
func Slice2IdsString(ids []int64) string {
arr := make([]string, len(ids))
for i, id := range ids {
arr[i] = fmt.Sprintf("%d", id)
}
s := ""
s = strings.Join(arr, ",")
return s
}
106 changes: 106 additions & 0 deletions Language_Specification/build-in-type/str/str_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package str

import (
"reflect"
"testing"
)

func TestIdsString2Slice(t *testing.T) {
type args struct {
ids string
}
tests := []struct {
name string
args args
want []int64
}{
{
name: "IdsString2Slice",
args: args{ids: "1,2,3"},
want: []int64{1, 2, 3},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := IdsString2Slice(tt.args.ids); !reflect.DeepEqual(got, tt.want) {
t.Errorf("String2SliceInt64() = %v, want %v", got, tt.want)
}
})
}
}

func TestSlice2IdsString(t *testing.T) {
type args struct {
ids []int64
}
tests := []struct {
name string
args args
want string
}{
{
name: "IdsString2Slice",
args: args{
ids: []int64{1, 2, 3},
},
want: "1,2,3",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Slice2IdsString(tt.args.ids); got != tt.want {
t.Errorf("Slice2IdsString() = %v, want %v", got, tt.want)
}
})
}
}

func TestBase64Encode(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want string
}{
{
name: "Base64Encode",
args: args{s: "sss"},
want: "c3Nz",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Base64Encode(tt.args.s); got != tt.want {
t.Errorf("Base64Encode() = %v, want %v", got, tt.want)
}
})
}
}

func TestBase64Decode(t *testing.T) {
type args struct {
s string
}
tests := []struct {
name string
args args
want string
}{
{
name: "Base64Decode",
args: args{
s: "c3Nz",
},
want: "sss",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Base64Decode(tt.args.s); got != tt.want {
t.Errorf("Base64Decode() = %v, want %v", got, tt.want)
}
})
}
}
8 changes: 0 additions & 8 deletions Language_Specification/build-in-type/string/string.go

This file was deleted.

26 changes: 0 additions & 26 deletions Language_Specification/build-in-type/string/string_cheat_sheet.go

This file was deleted.

8 changes: 4 additions & 4 deletions Language_Specification/constant/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ package main
import "fmt"

const (
A1 = iota // 如同数据库里面的serial, 自增, iota默认Increment by 1
A1 = iota // like mysql serial, auto increment, iota default increment by 1
A2
A3
)
const (
B1 = iota + 2 // start by iot + 2,即2, Increment by iot, 即1
B1 = iota + 2 // start by iot + 2, that is 2, Increment by iot, that is 1
B2
B3
)
const (
C1 = iota * 2 // start iot*2, 即0, Increment by iot * 2, 即2
C1 = iota * 2 // start iot*2, that 0, Increment by iot * 2, that is 2
C2
C3
C4
)
const (
D1 = 1 << iota // start by 1 , Increment by iot * iot
D1 = 1 << 2 // start by 1 , left shift 1
D2
D3
D4
Expand Down
50 changes: 25 additions & 25 deletions Language_Specification/enum/enum.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ import (
"fmt"
)

type ACTION_TYPE int32
type ACTION int32

const (
ACTION_TYPE_ACTION_EMPTY ACTION_TYPE = 0
ACTION_TYPE_ACTION_PICKUP ACTION_TYPE = 1
ACTION_TYPE_ACTION_PUTDOWN ACTION_TYPE = 2
ACTION_TYPE_ACTION_TOUCH ACTION_TYPE = 3
ACTION_TYPE_ACTION_APPROACH ACTION_TYPE = 4
EMPTY ACTION = iota
PICKUP
PUTDOWN
TOUCH
APPROACH
)

var ACTION_TYPE_name = map[int32]string{
0: "ACTION_EMPTY",
1: "ACTION_PICKUP",
2: "ACTION_PUTDOWN",
3: "ACTION_TOUCH",
4: "ACTION_APPROACH",
var ACTION_name = map[ACTION]string{
EMPTY: "EMPTY",
PICKUP: "PICKUP",
PUTDOWN: "PUTDOWN",
TOUCH: "TOUCH",
APPROACH: "APPROACH",
}

var ACTION_TYPE_value = map[string]int32{
"ACTION_EMPTY": 0,
"ACTION_PICKUP": 1,
"ACTION_PUTDOWN": 2,
"ACTION_TOUCH": 3,
"ACTION_APPROACH": 4,
var ACTION_value = map[string]ACTION{
"EMPTY": EMPTY,
"PICKUP": PICKUP,
"PUTDOWN": PUTDOWN,
"TOUCH": TOUCH,
"APPROACH": APPROACH,
}

func (x ACTION_TYPE) String() string {
return ACTION_TYPE_name[int32(x)]
func (x ACTION) String() string {
return ACTION_name[x]
}

func main() {
fmt.Println("by const:", ACTION_TYPE_ACTION_PICKUP)
fmt.Println("by key:", ACTION_TYPE(3))
fmt.Println("by value", ACTION_TYPE_value["ACTION_PICKUP"])
fmt.Printf("enum: %d \n", ACTION_TYPE_ACTION_PICKUP)
fmt.Printf("enum string: %v \n", ACTION_TYPE_ACTION_PICKUP)
fmt.Println("by const:", PICKUP)
fmt.Println("by key:", ACTION(3))
fmt.Println("by value", ACTION_value["PICKUP"])
fmt.Printf("enum: %d \n", PICKUP)
fmt.Printf("enum string: %s \n", PICKUP)
}
2 changes: 1 addition & 1 deletion Language_Specification/exporting/exporting.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package main

import (
"fmt"
"gobyexample/Language_Specification/exporting/codes"
"ultimate-go/Language_Specification/exporting/codes"
)

// -------------------
Expand Down
12 changes: 12 additions & 0 deletions Language_Specification/import/bar/bar.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package bar

import (
"fmt"
)

type Bar struct {
}

func (b *Bar) Bar() {
fmt.Println("this bar")
}
Loading