Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- Data type



  Introduction to GoLang generics and advanced usage

Generics in Go allow you to write code that can work with multiple types of data, without having to write separate versions of the code for each type. This can make your code more flexible and easier to maintain, as you only need to write and test the code once, rather than maintaining multiple versions. To use generics in Go, you first need to define a type parameter, which is a placeholder for the type that the code will work with. For example, you might define a type parameter called "T" like...

   GOLANG,GENERICS     2022-12-17 05:12:21

  Data type in MySQL

For both small free database space and large e-commerce websites, reasonable database table structure design is essential. To achieve this, it requires us to have a full understanding of commonly used data types in database system. Below we share some knowledge about data types in MySQL.1. Numeric typesThe numeric types can be classified as : integer, float and decimal type.The so-called "decimal" refers DECIMAL and NUMERIC, they are of the same type. Strictly speaking it is not a numeric type, ...

   MySQL, Data type,VARCHAR     2013-01-01 10:56:06

  Time to think about supporting max/min functions for integers in GoLang

Sometime back we wrote a post explaining why there is no max/min function support for integers in GoLang, one of the reasons is that no overloading is supported and the function name has been used for other numeric types float64. To solve this problem and make max/min function support integer as well, either GoLang should support overloading like in Java or the same set of functions need to be created in a different package other than standard math. These don't look like good options as overload...

   MIN,MAX,GENERICS,GOLANG     2021-07-24 03:14:42

  Removing duplicates in sql

In modern web development, it’s standard practice to make use of a database abstraction layer, typically an Object-Relational Mapper based on either the Active Record pattern or the Data Mapper pattern. There are several pros and cons to this which are fairly well established, so I’ll spare us all from enumerating them all right now. One established pro worth mentioning is that these systems typically provide a high level interface for fetching data, often removing the need to ...

   SQL,Duplicate,Remove,Web design     2012-01-05 08:20:13

  How to optimize MySQL insert statement

For a big data system, one problem is the data access efficiency, one more problem is that the data insertion is very slow. We had a service system, the data loading process would take 4-5 hours. This time consuming operation is risky since if the program is interrupted during the loading process, it might be rerun, this will be troublesome. So it's necessary to improve the insertion efficiency for big data systems. Here we provide two optimization suggestions. 1. Combine multiple insert stateme...

   MySQL,insert,optimization     2012-10-24 22:03:13

  Empty slice vs nil slice in GoLang

In Go, there is a type called slice which is built on top of array. It's a very convenient type when we want to handle a group of data. This post will explain a subtle but tricky difference between empty slice and nil slice. A nil slice is a slice has a length and capacity of zero and has no underlying array. The zero value of slice is nil. If a slice is declared like below, it is a nil slice. package main import "fmt" func main() { var a []string fmt.Println(a == nil) } The output will be t...

   GOLANG,JSON,EMPTY SLICE,NIL SLICE     2018-10-18 09:25:21

  How to check whether a struct implements an interface in GoLang

Unlike other programming languages like Java, when implementing an interface in GoLang, there is no syntax like below to explicit tell the relationship: type I interface { } type A struct implements I { } When looking at the code or running the code in GoLang, it might lead to a case one doesn't know whether a struct implements interface before trying to use it as some interface. According to GoLang spec, as long as a struct implements all functions of an interface, it is considered as having i...

   GOLANG,INTERFACE,IMPLEMENTATION,CHECK     2020-05-03 00:05:54

  Can a == true && a == false be true in JavaScript?

JavaScript is a weak typed language and it has a loose comparison feature where two objects/values of different type can be compared using == operator. This provides developers great flexibility and confusion at the same time.  Before understanding how == works in JavaScript, can you first answer the question in the post title? Can a == true && a == false be true in JavaScript? Normally, we would think that this expression will always return false since a can be either true or ...

   JAVASCRIPT,COMPARISON,INTERVIEW QUESTION,==     2018-03-25 03:39:43

  Learn Emacs: Keyboard Macros

An emacs keyboard macro is just a recording of user input into emacs, which means that most anything you can do in emacs can be recorded as a macro. Read that again. Pretty powerful.Here’s how it works. To start recording, typeC-x (and input the commands in your macro. Then typeC-x )to stop recording. Then typeC-x eto apply the macro once, orC-u 0 C-x eto apply the macro until the bell rings or end of buffer is reachedKeep in mind that you must not ring the bell when defining a keyboard m...

   Emac,Macro,Code,Example     2011-11-10 10:45:47

  new() and make() in GoLang

GoLang is a modern, statically typed, compiled programming language designed for building scalable, concurrent, and efficient software. It provides various built-in functions and features that help developers write concise and efficient code. Among them are the new() and make() functions, which may appear similar at first glance but serve different purposes in GoLang and are crucial for memory allocation and data initialization. In this blog article, we will explore the differences between the n...

   NEW,MAKE,GOLANG     2023-11-18 13:43:25