Skip to content

Commit ec814d8

Browse files
committed
add languages links and logos
1 parent 314e634 commit ec814d8

File tree

6 files changed

+159
-7
lines changed

6 files changed

+159
-7
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
---
2+
id: index-golang
3+
title: Go and Redis
4+
sidebar_label: Go
5+
slug: /develop/golang/
6+
---
7+
8+
import Tabs from '@theme/Tabs';
9+
import TabItem from '@theme/TabItem';
10+
import useBaseUrl from '@docusaurus/useBaseUrl';
11+
12+
Find tutorials, examples and technical articles that will help you to develop with Redis and Golang.
13+
14+
## Getting Started
15+
16+
Golang community has built many client libraries that you can find [here](https://redis.io/clients#go).
17+
For your first steps with Golang and Redis, this article will show how to use the recommended library: [redigo](https://github.com/gomodule/redigo).
18+
19+
20+
<Tabs
21+
defaultValue="redigo"
22+
values={[
23+
{label: 'Redigo', value: 'redigo'},
24+
]}>
25+
<TabItem value="redigo">
26+
27+
### Getting Started with redigo
28+
29+
30+
The `redigo` library is located in the `https://github.com/gomodule/redigo` that you must import in your application.
31+
32+
33+
1. Import the `redigo` module
34+
35+
```bash
36+
go get github.com/gomodule/redigo/redis
37+
```
38+
39+
```go
40+
import (
41+
"fmt"
42+
"context"
43+
"github.com/gomodule/redigo/redis"
44+
)
45+
```
46+
47+
1. Create a connection pool
48+
49+
```go
50+
func newPool() *redis.Pool {
51+
return &redis.Pool{
52+
MaxIdle: 80,
53+
MaxActive: 12000,
54+
Dial: func() (redis.Conn, error) {
55+
c, err := redis.Dial("tcp", ":6379")
56+
if err != nil {
57+
panic(err.Error())
58+
}
59+
return c, err
60+
},
61+
}
62+
}
63+
```
64+
65+
1. Write your application code
66+
67+
```go
68+
package main
69+
70+
import (
71+
"fmt"
72+
73+
"github.com/gomodule/redigo/redis"
74+
)
75+
76+
var pool = newPool()
77+
78+
func main() {
79+
80+
client := pool.Get()
81+
defer client.Close()
82+
83+
_, err := client.Do("SET", "mykey", "Hello from redigo!")
84+
if err != nil {
85+
panic(err)
86+
}
87+
88+
value, err := client.Do("GET", "mykey")
89+
if err != nil {
90+
panic(err)
91+
}
92+
93+
fmt.Printf("%s \n", value)
94+
95+
_, err = client.Do("ZADD", "vehicles", 4, "car")
96+
if err != nil {
97+
panic(err)
98+
}
99+
_, err = client.Do("ZADD", "vehicles", 2, "bike")
100+
if err != nil {
101+
panic(err)
102+
}
103+
104+
vehicles, err := client.Do("ZRANGE", "vehicles", 0, -1, "WITHSCORES")
105+
if err != nil {
106+
panic(err)
107+
}
108+
fmt.Printf("%s \n", vehicles)
109+
110+
111+
}
112+
113+
func newPool() *redis.Pool {
114+
return &redis.Pool{
115+
MaxIdle: 80,
116+
MaxActive: 12000,
117+
Dial: func() (redis.Conn, error) {
118+
c, err := redis.Dial("tcp", ":6379")
119+
if err != nil {
120+
panic(err.Error())
121+
}
122+
return c, err
123+
},
124+
}
125+
}
126+
```
127+
128+
Find more information about Golang & Redis connections in the "[Redis Connect](https://github.com/redis-developer/redis-connect/tree/master/golang/redigo)".
129+
130+
131+
</TabItem>
132+
</Tabs>

src/pages/index.js

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,34 @@ function Home() {
8383
<h1>Resources by Languages</h1>
8484
<p className="">Find documentation, sample code and tools to develop with your favorite language.</p>
8585
<div className="row text--center">
86-
<a class="col col--2" href={useBaseUrl('docs/develop/java')}>Java</a>
87-
88-
<a class="col col--2" href={useBaseUrl('docs/develop/python')}>Python</a>
89-
90-
<a class="col col--2" href={useBaseUrl('docs/develop/node')}>Node.js</a>
91-
92-
<a class="col col--2" href={useBaseUrl('docs/develop/golang')}>Golang</a>
9386

87+
<div className=" col col--2 text--center">
88+
<a href={useBaseUrl('docs/develop/java')}>
89+
<img src={useBaseUrl('/img/logos/java.png')} />
90+
<h4>Java</h4>
91+
</a>
92+
</div>
93+
94+
<div className=" col col--2 text--center">
95+
<a href={useBaseUrl('docs/develop/python')}>
96+
<img src={useBaseUrl('/img/logos/python.png')} />
97+
<h4>Python</h4>
98+
</a>
99+
</div>
100+
101+
<div className=" col col--2 text--center">
102+
<a href={useBaseUrl('docs/develop/node')}>
103+
<img src={useBaseUrl('/img/logos/nodejs.png')} />
104+
<h4>Node.js</h4>
105+
</a>
106+
</div>
107+
108+
<div className=" col col--2 text--center">
109+
<a href={useBaseUrl('docs/develop/golang')}>
110+
<img src={useBaseUrl('/img/logos/golang.png')} />
111+
<h4>Go</h4>
112+
</a>
113+
</div>
94114

95115
</div>
96116

static/img/logos/golang.png

2.64 KB
Loading

static/img/logos/java.png

1.25 KB
Loading

static/img/logos/nodejs.png

3.96 KB
Loading

static/img/logos/python.png

1.54 KB
Loading

0 commit comments

Comments
 (0)