GO工具、GO游戏框架、Streams

一、添加依赖库、由于go受到网络、需要配置一下

参考:https://goproxy.io/zh/

Go模块的全局代理,类似nodejs中的cnpm、npm的功能
GO工具、GO游戏框架、Streams_第1张图片

GO工具、GO游戏框架、Streams_第2张图片

二、生成二维码

package main

import qrcode "github.com/skip2/go-qrcode"
import "fmt"

func main() {
	err := qrcode.WriteFile("http://www.baidu.com", qrcode.Medium, 500, "go-qrcode.png")
	if err != nil {
		fmt.Println("write error")
	}
}

GO工具、GO游戏框架、Streams_第3张图片
在这里插入图片描述

三、LollipopGo

全球服游戏服务器框架,目前协议支持websocket、http及RPC,采用状态同步。

GO工具、GO游戏框架、Streams_第4张图片
参考:https://github.com/Golangltd/LollipopGo

四、pravega (Streams的开源分布式存储服务)

介绍:Pravega是实现Streams的开源分布式存储服务。Pravega为连续和无限制的数据提供了新的存储抽象-流。Pravega流是持久的,弹性的,仅附加的,无边界的字节序列,具有良好的性能和强的一致性。

开源地址:https://github.com/pravega/pravega

官网:http://pravega.io/

package io.pravega.common.util;

import java.util.HashMap;
import java.util.Map;
import java.util.Collection;
import java.util.Collections;
import java.util.Set;

public class CopyOnWriteHashMap<K, V> implements Map<K, V> {

    private volatile Map<K, V> contents;

    public CopyOnWriteHashMap() {
        this.contents = new HashMap<>();
    }

    public CopyOnWriteHashMap(Map<K, V> map) {
        this.contents = Collections.unmodifiableMap(map);
    }

    // Provide access to  the inner map that this class is wrapping.

    public Map<K, V> getInnerMap() {
        return this.contents;
    }

    // End region.

    // Methods mutating internal state.

    @Override
    public synchronized V put(K k, V v) {
        Map<K, V> newMap = new HashMap<>(this.contents);
        V result = newMap.put(k, v);
        this.contents = Collections.unmodifiableMap(newMap);
        return result;
    }

    @Override
    public synchronized void putAll(Map<? extends K, ? extends V> entries) {
        Map<K, V> newMap = new HashMap<>(this.contents);
        newMap.putAll(entries);
        this.contents = Collections.unmodifiableMap(newMap);
    }

    @Override
    public synchronized V putIfAbsent(K k, V v) {
        return (!containsKey(k)) ? put(k, v) : get(k);
    }

    @Override
    public synchronized V remove(Object key) {
        Map<K, V> newMap = new HashMap<>(this.contents);
        V result = newMap.remove(key);
        this.contents = Collections.unmodifiableMap(newMap);
        return result;
    }

    @Override
    public synchronized boolean remove(Object k, Object v) {
        if (containsKey(k) && get(k).equals(v)) {
            remove(k);
            return true;
        }
        return false;
    }

    @Override
    public synchronized boolean replace(K k, V original, V replacement) {
        if (containsKey(k) && get(k).equals(original)) {
            put(k, replacement);
            return true;
        }
        return false;
    }

    @Override
    public synchronized V replace(K k, V v) {
        return (containsKey(k)) ? put(k, v) : null;
    }

    // End region

    // Read-only methods.

    @Override
    public boolean containsKey(Object k) {
        return contents.containsKey(k);
    }

    @Override
    public boolean containsValue(Object v) {
        return contents.containsValue(v);
    }

    @Override
    public Set<java.util.Map.Entry<K, V>> entrySet() {
        return contents.entrySet();
    }

    @Override
    public V get(Object k) {
        return contents.get(k);
    }

    @Override
    public boolean isEmpty() {
        return contents.isEmpty();
    }

    @Override
    public Set<K> keySet() {
        return contents.keySet();
    }

    @Override
    public int size() {
        return contents.size();
    }

    @Override
    public Collection<V> values() {
        return contents.values();
    }

    @Override
    public synchronized void clear() {
        this.contents = new HashMap<>();
    }

    // End region

}
package io.pravega.common.util;

import java.time.Duration;
import java.util.concurrent.CompletableFuture;


public interface AsyncMap<K, V> {
   
    CompletableFuture<Void> put(K key, V value, Duration timeout);

  
    CompletableFuture<V> get(K key, Duration timeout);

  
    CompletableFuture<Void> remove(K key, Duration timeout);
}

你可能感兴趣的:(GO开发,JAVA开发,GO工具,GO游戏框架,Streams,goproxy.io,pravega)