Tags » Golang

What programming language to use for a brand new project?

Try as I might I can’t bring myself to like JavaScript. In a debate with a colleague, I was asked, “If not JavaScript, what language would you use if you had to start over?” 706 more words

Analysis

Knative Eventing: Part 2 - streaming CloudEvents to a UI

I’ve been looking at Knative eventing a fair bit lately and one of the things I have been doing is building an eventing demo (the first part of which can be found… 839 more words

Kubernetes

Golang类消息循环的线程安全模式

场景

为了提高性能,减少数据库的查询操作,一个Service维护着全部生命周期活跃的Foo对象。Foo的定义如下:

struct Foo {
    Id int64
    RootId int64
}

内部使用map*Foo数据结构。map的key就是Foo对象的ID。绝大部分的查询都是根据Foo的ID返回Foo对象,使用map确实高效。小部分场景是查询是查询RootId相同的一组Foo。这个通过遍历整个map来实现,现阶段的数据量级还不需要通过建立RootId索引来提高性能。除了查询之后,还有大量的插入和更新动作。最关键的是,有多个goroutine同时操作这个Service。

go的map对象不能并发读写,否则会触发panic. 标准库提供了线程安全的sync.Map。但是,golang还不支持范型,因此这个sync.Map的key和Value都是interface{}。由使用者负责类型安全和类型转换。sync.Map的插入和更新都是原子化操作,但遍历 278 more words

Computers And Internet

Go - Hello World

Desde que inicié mi carrera me he especializado en Java, y a su vez, había tenido algunos acercamientos a Python, lenguaje que me encanta por su sencillez y poder. 793 more words

Holamundo

EventStore and Go

Eventstore is a great event sourcing system for those situations where you want realtime (ish) events to process as opposed to querying a regular RDMS. 1,430 more words

Logging #9: Observability via Logging

Problem

Application monitoring has grown more complex in the days of SaaS and microservices.

Solution

Observability, which for me means the ability to analyze the system usually based on its… 540 more words

Reverse a string using recursion

This problem can be simply stated as reverse(str) = reverse(str) + str[0]. Below is the Golang code:

package main

import (
	"fmt"
)

func reverseString(input string) {
	if len(input) == 0 {
		return
	}
	reverseString(input)
	fmt.Print(string(input[0]))
}

func main() {
	reverseString("Santak Dalai")
}

… 60 more words
Tech