add version and translate all pages
This commit is contained in:
@@ -8,19 +8,19 @@ type Client interface {
|
||||
GetClientVersion() int
|
||||
}
|
||||
|
||||
func NewClient(clientVersion int) (error, Client) {
|
||||
func NewClient(clientVersion int) (Client, error) {
|
||||
|
||||
isCompatible := ServerClientIsCompatibleWithClient(clientVersion)
|
||||
|
||||
if !isCompatible {
|
||||
return fmt.Errorf("You client version %d is not compatible with the server verison %d", clientVersion, SERVER_VERSION), nil
|
||||
return nil, fmt.Errorf("client version %d is not compatible with the server version %d", clientVersion, SERVER_VERSION)
|
||||
}
|
||||
|
||||
client := ClientVerisonOne{
|
||||
Version: clientVersion,
|
||||
}
|
||||
|
||||
return nil, &client
|
||||
return &client, nil
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"errors"
|
||||
)
|
||||
|
||||
type Document struct {
|
||||
@@ -37,19 +37,19 @@ func IsDirectory(documentType int) bool {
|
||||
return DIRECTORY == documentType
|
||||
}
|
||||
|
||||
func NewDocument(documentName string, documentType int, documentVersion int) (error, *Document) {
|
||||
func NewDocument(documentName string, documentType int, documentVersion int) (*Document, error) {
|
||||
|
||||
documentTypeIsValid := IsDocumentTypeValid(documentType)
|
||||
|
||||
if !documentTypeIsValid {
|
||||
return fmt.Errorf(ERROR_DOCUMENT_TYPE), nil
|
||||
return nil, errors.New(ERROR_DOCUMENT_TYPE)
|
||||
}
|
||||
|
||||
return nil, &Document{
|
||||
return &Document{
|
||||
Name: &documentName,
|
||||
Type: documentType,
|
||||
Version: documentVersion,
|
||||
}
|
||||
}, nil
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ type User struct {
|
||||
Username string
|
||||
}
|
||||
|
||||
func NewUser(username string) (error, *User) {
|
||||
return nil, &User{
|
||||
func NewUser(username string) (*User, error) {
|
||||
return &User{
|
||||
Username: username,
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user