The intersection of a linear code and its dual is called the hull of this code. The code is a linear complementary dual (LCD) code if the dimension of its hull is zero. In this paper, we develop a method to construct LCD codes and linear codes with one-dimensional hull by association schemes. One of constructions in this paper generalizes that of linear codes associated with Gauss periods given in [5]. In addition, we present a generalized construction of linear codes, which can provide more LCD codes and linear codes with onedimensional hull. We also present some examples of LCD MDS, LCD almost MDS codes, and MDS, almost MDS codes with one-dimensional hull from our constructions.