С типами проявилась еще особенность языка Go — переменная типа string не может принимать значение nil, но из БД может прийти как пустая строка, так и NULL. Для решения этой проблемы в пакете database/sql есть решение — использовать специальные struсt, которые хранят в себе значение и признак, NULL это или нет.
"""
Define a represention for a grammar of the given language along with an
interpreter that uses the representation to interpret sentences in the
language.
"""
import abc
class AbstractExpression(metaclass=abc.ABCMeta):
"""
Declare an abstract Interpret operation that is common to all nodes
in the abstract syntax tree.
"""
@abc.abstractmethod
def interpret(self):
pass
class NonterminalExpression(AbstractExpression):
"""
Implement an Interpret operation for nonterminal symbols in the grammar.
"""
def __init__(self, expression):
self._expression = expression
def interpret(self):
self._expression.interpret()
class TerminalExpression(AbstractExpression):
"""
Implement an Interpret operation associated with terminal symbols in
the grammar.
"""
def interpret(self):
pass
def main():
abstract_syntax_tree = NonterminalExpression(TerminalExpression())
abstract_syntax_tree.interpret()
if __name__ == "__main__":
main()
Go + HTTP/2
Можно также использовать указатель на строчку.